mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Ensure symbol list node is either NODE_STR or NODE_DSTR
This commit is contained in:
parent
c060bdc2b4
commit
bb40c5cbe9
Notes:
git
2021-01-14 16:59:48 +09:00
1 changed files with 8 additions and 3 deletions
11
parse.y
11
parse.y
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue