Skip to content

Commit

Permalink
Merge pull request #3117 from ruby/disallow-infix-after-label
Browse files Browse the repository at this point in the history
Disallow infix operators after label
  • Loading branch information
kddnewton committed Oct 1, 2024
2 parents de19f0a + 06af2e1 commit fb25917
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -21629,6 +21629,13 @@ parse_expression(pm_parser_t *parser, pm_binding_power_t binding_power, bool acc
return node;
}
break;
case PM_SYMBOL_NODE:
// If we have a symbol node that is being parsed as a label, then we
// need to immediately return, because there should never be an
// infix operator following this node.
if (pm_symbol_node_label_p(node)) {
return node;
}
default:
break;
}
Expand Down
6 changes: 6 additions & 0 deletions test/prism/errors/infix_after_label.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ 'a':.upcase => 1 }
^ unexpected '.'; expected a value in the hash literal
^ expected a `}` to close the hash literal
^ unexpected '}', expecting end-of-input
^ unexpected '}', ignoring it

0 comments on commit fb25917

Please sign in to comment.