mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Allow anonymous memberless Struct
Previously, named memberless Structs were allowed, but anonymous memberless Structs were not. Fixes [Bug #19416]
This commit is contained in:
parent
73fc81199d
commit
f8e7048348
Notes:
git
2023-04-24 14:37:49 +00:00
3 changed files with 18 additions and 8 deletions
11
struct.c
11
struct.c
|
@ -637,17 +637,14 @@ rb_struct_define_under(VALUE outer, const char *name, ...)
|
|||
static VALUE
|
||||
rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
VALUE name, rest, keyword_init = Qnil;
|
||||
VALUE name = Qnil, rest, keyword_init = Qnil;
|
||||
long i;
|
||||
VALUE st;
|
||||
VALUE opt;
|
||||
|
||||
argc = rb_scan_args(argc, argv, "1*:", NULL, NULL, &opt);
|
||||
name = argv[0];
|
||||
if (SYMBOL_P(name)) {
|
||||
name = Qnil;
|
||||
}
|
||||
else {
|
||||
argc = rb_scan_args(argc, argv, "0*:", NULL, &opt);
|
||||
if (argc >= 1 && !SYMBOL_P(argv[0])) {
|
||||
name = argv[0];
|
||||
--argc;
|
||||
++argv;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue