diff options
| -rw-r--r-- | prism/prism.c | 6 | ||||
| -rw-r--r-- | test/prism/fixtures/case_in_hash_key.txt | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/prism/prism.c b/prism/prism.c index 9d2598e746..4d2c372d5d 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -22176,6 +22176,12 @@ parse_expression(pm_parser_t *parser, pm_binding_power_t binding_power, bool acc ) { node = parse_expression_infix(parser, node, binding_power, current_binding_powers.right, accepts_command_call, (uint16_t) (depth + 1)); + if (context_terminator(parser->current_context->context, &parser->current)) { + // If this token terminates the current context, then we need to + // stop parsing the expression, as it has become a statement. + return node; + } + switch (PM_NODE_TYPE(node)) { case PM_MULTI_WRITE_NODE: // Multi-write nodes are statements, and cannot be followed by diff --git a/test/prism/fixtures/case_in_hash_key.txt b/test/prism/fixtures/case_in_hash_key.txt new file mode 100644 index 0000000000..75ac8a846f --- /dev/null +++ b/test/prism/fixtures/case_in_hash_key.txt @@ -0,0 +1,6 @@ +case 1 +in 2 + A.print message: +in 3 + A.print message: +end |
