Use RTEST and add test for GH-6832

Technically we shouldn't see Qfalse now, but RTEST also compiles down to
just one branch anyways. Pretty contrived issue, but easy to fix.
This commit is contained in:
Alan Wu 2022-11-30 15:04:31 -05:00
parent 4b9d10b833
commit 5752d11f1f
Notes: git 2022-11-30 21:28:03 +00:00
2 changed files with 9 additions and 1 deletions

View file

@ -48,7 +48,7 @@ struct_ivar_get(VALUE c, ID id)
for (;;) {
c = rb_class_superclass(c);
if (c == 0 || c == rb_cStruct || c == rb_cData || c == Qnil)
if (c == rb_cStruct || c == rb_cData || !RTEST(c))
return Qnil;
RUBY_ASSERT(RB_TYPE_P(c, T_CLASS));
ivar = rb_attr_get(c, id);