summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/compile.c b/compile.c
index fee2fafc8d..62b5bbc490 100644
--- a/compile.c
+++ b/compile.c
@@ -5859,17 +5859,22 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
expr_type = DEFINED_FALSE;
break;
+ case NODE_HASH:
case NODE_LIST:{
- const NODE *vals = node;
+ const NODE *vals = (nd_type(node) == NODE_HASH) ? RNODE_HASH(node)->nd_head : node;
- do {
- defined_expr0(iseq, ret, RNODE_LIST(vals)->nd_head, lfinish, Qfalse, false);
+ if (vals) {
+ do {
+ if (RNODE_LIST(vals)->nd_head) {
+ defined_expr0(iseq, ret, RNODE_LIST(vals)->nd_head, lfinish, Qfalse, false);
- if (!lfinish[1]) {
- lfinish[1] = NEW_LABEL(line);
- }
- ADD_INSNL(ret, line_node, branchunless, lfinish[1]);
- } while ((vals = RNODE_LIST(vals)->nd_next) != NULL);
+ if (!lfinish[1]) {
+ lfinish[1] = NEW_LABEL(line);
+ }
+ ADD_INSNL(ret, line_node, branchunless, lfinish[1]);
+ }
+ } while ((vals = RNODE_LIST(vals)->nd_next) != NULL);
+ }
}
/* fall through */
case NODE_STR:
@@ -5889,6 +5894,15 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
expr_type = DEFINED_EXPR;
break;
+ case NODE_SPLAT:
+ defined_expr0(iseq, ret, RNODE_LIST(node)->nd_head, lfinish, Qfalse, false);
+ if (!lfinish[1]) {
+ lfinish[1] = NEW_LABEL(line);
+ }
+ ADD_INSNL(ret, line_node, branchunless, lfinish[1]);
+ expr_type = DEFINED_EXPR;
+ break;
+
/* variables */
case NODE_LVAR:
case NODE_DVAR: