summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-01-14 16:13:26 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-01-14 16:13:26 +0900
commitbb40c5cbe977de9f36a2a739e94e9b2fd4496b6e (patch)
tree9998a11ccce34d9ad71bcffea3750d504d4fb868 /parse.y
parentc060bdc2b4ab8eeef5374f4174f5de48ab936d74 (diff)
Ensure symbol list node is either NODE_STR or NODE_DSTR
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4069
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y11
1 files changed, 8 insertions, 3 deletions
diff --git a/parse.y b/parse.y
index 538153cc7a4..29784f3c6a5 100644
--- a/parse.y
+++ b/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);
}