Assert that rb_sym2str returns 0 or a T_STRING

This commit is contained in:
Peter Zhu 2024-04-05 16:14:24 -04:00
parent e50590a541
commit 37490474c4

View file

@ -953,12 +953,17 @@ rb_id2sym(ID x)
VALUE VALUE
rb_sym2str(VALUE sym) rb_sym2str(VALUE sym)
{ {
VALUE str;
if (DYNAMIC_SYM_P(sym)) { if (DYNAMIC_SYM_P(sym)) {
return RSYMBOL(sym)->fstr; str = RSYMBOL(sym)->fstr;
RUBY_ASSERT(BUILTIN_TYPE(str) == T_STRING);
} }
else { else {
return rb_id2str(STATIC_SYM2ID(sym)); str = rb_id2str(STATIC_SYM2ID(sym));
RUBY_ASSERT(str == 0 || BUILTIN_TYPE(str) == T_STRING);
} }
return str;
} }
VALUE VALUE