Skip to content

Commit

Permalink
Assert that rb_sym2str returns 0 or a T_STRING
Browse files Browse the repository at this point in the history
  • Loading branch information
peterzhu2118 committed Apr 5, 2024
1 parent e50590a commit 3749047
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions symbol.c
Expand Up @@ -953,12 +953,17 @@ rb_id2sym(ID x)
VALUE
rb_sym2str(VALUE sym)
{
VALUE str;
if (DYNAMIC_SYM_P(sym)) {
return RSYMBOL(sym)->fstr;
str = RSYMBOL(sym)->fstr;
RUBY_ASSERT(BUILTIN_TYPE(str) == T_STRING);
}
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
Expand Down

0 comments on commit 3749047

Please sign in to comment.