Skip to content

Commit

Permalink
Ensure symbol list node is either NODE_STR or NODE_DSTR
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Jan 14, 2021
1 parent c060bdc commit bb40c5c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -10362,12 +10362,17 @@ new_defined(struct parser_params *p, NODE *expr, const YYLTYPE *loc)
static NODE*
symbol_append(struct parser_params *p, NODE *symbols, NODE *symbol)
{
if (nd_type(symbol) == NODE_DSTR) {
enum node_type type = nd_type(symbol);
switch (type) {
case NODE_DSTR:
nd_set_type(symbol, NODE_DSYM);
}
else {
break;
case NODE_STR:
nd_set_type(symbol, NODE_LIT);
RB_OBJ_WRITTEN(p->ast, Qnil, symbol->nd_lit = rb_str_intern(symbol->nd_lit));
break;
default:
compile_error(p, "unexpected node as symbol: %s", ruby_node_name(type));
}
return list_append(p, symbols, symbol);
}
Expand Down

0 comments on commit bb40c5c

Please sign in to comment.