1
0
Fork 0
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:
Nobuyoshi Nakada 2021-01-14 16:13:26 +09:00
parent c060bdc2b4
commit bb40c5cbe9
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
Notes: git 2021-01-14 16:59:48 +09:00

11
parse.y
View file

@ -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);
}