Allow anonymous memberless Struct

Previously, named memberless Structs were allowed, but anonymous
memberless Structs were not.

Fixes [Bug #19416]
This commit is contained in:
Jeremy Evans 2023-03-23 13:44:04 -07:00
parent 73fc81199d
commit f8e7048348
Notes: git 2023-04-24 14:37:49 +00:00
3 changed files with 18 additions and 8 deletions

View file

@ -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;
}