Skip to content

Commit

Permalink
fix: Prevent use of labels such as start= from generating code that c…
Browse files Browse the repository at this point in the history
…lashes with builtin funcs (antlr#4161)

Signed-off-by: Jim.Idle <jimi@idle.ws>
  • Loading branch information
Jim Idle authored and jimidle committed Mar 10, 2023
1 parent 4f9d23c commit 6e2e6f4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tool/src/org/antlr/v4/codegen/target/GoTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ public class GoTarget extends Target {
"SetInvokingState", "SetParent", "String",

// misc
"rule", "parserRule", "action"
"rule", "parserRule", "action",

// the use of start or stop abd others as a label name will cause the generation of a GetStart() or GetStop() method, which
// then clashes with the GetStart() or GetStop() method that is generated by the code gen for the rule. So, we need to
// convert it. This is not ideal as it will still probably confuse authors of parse listeners etc. but the code will
// compile. This is a proof of Hyrum's law.
"start", "stop", "exception"
));

private static final boolean DO_GOFMT = !Boolean.parseBoolean(System.getenv("ANTLR_GO_DISABLE_GOFMT"))
Expand Down

0 comments on commit 6e2e6f4

Please sign in to comment.