Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -17393,6 +17393,14 @@ parse_pattern_primitive(pm_parser_t *parser, pm_constant_id_list_t *captures, pm
// If we found a label, we need to immediately return to the caller.
if (pm_symbol_node_label_p(node)) return node;

// Call nodes (arithmetic operations) are not allowed in patterns
if (PM_NODE_TYPE(node) == PM_CALL_NODE) {
pm_parser_err_node(parser, node, diag_id);
pm_missing_node_t *missing_node = pm_missing_node_create(parser, node->location.start, node->location.end);
pm_node_destroy(parser, node);
return (pm_node_t *) missing_node;
}

// Now that we have a primitive, we need to check if it's part of a range.
if (accept2(parser, PM_TOKEN_DOT_DOT, PM_TOKEN_DOT_DOT_DOT)) {
pm_token_t operator = parser->previous;
Expand Down
3 changes: 3 additions & 0 deletions test/prism/errors/pattern_arithmetic_expressions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
case 1; in -1**2; end
^~~~~ expected a pattern expression after the `in` keyword