summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2024-03-13 10:06:19 -0400
committerKevin Newton <kddnewton@gmail.com>2024-03-13 10:06:19 -0400
commit22217e70c27dcd1a6d6dc75c78a3a2288dda8985 (patch)
tree8384077366eff48341c2620bfab0e127fa3578e6
parentc6089b56547daa61e0d20763bae3066fe311e91b (diff)
[PRISM] Handle parentheses in patterns in prism
-rw-r--r--prism_compile.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/prism_compile.c b/prism_compile.c
index fcc9eddfbb..68365464b5 100644
--- a/prism_compile.c
+++ b/prism_compile.c
@@ -2358,6 +2358,12 @@ pm_compile_pattern(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t
CHECK(pm_compile_pattern(iseq, scope_node, cast->right, ret, matched_label, unmatched_label, in_single_pattern, true, true, base_index));
break;
}
+ case PM_PARENTHESES_NODE:
+ // Parentheses are allowed to wrap expressions in pattern matching and
+ // they do nothing since they can only wrap individual expressions and
+ // not groups. In this case we'll recurse back into this same function
+ // with the body of the parentheses.
+ return pm_compile_pattern(iseq, scope_node, ((pm_parentheses_node_t *) node)->body, ret, matched_label, unmatched_label, in_single_pattern, in_alternation_pattern, use_deconstructed_cache, base_index);
case PM_PINNED_EXPRESSION_NODE:
// Pinned expressions are a way to match against the value of an
// expression that should be evaluated at runtime. This looks like: