Skip to content

Commit b0713e2

Browse files
Jim Idlejimidle
authored andcommitted
fix: Prevent use of labels such as start= from generating code that clashes with builtin funcs (antlr#4161)
Signed-off-by: Jim.Idle <[email protected]>
1 parent 4ab43ac commit b0713e2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tool/src/org/antlr/v4/codegen/target/GoTarget.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ public class GoTarget extends Target {
4444
"SetInvokingState", "SetParent", "String",
4545

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

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

0 commit comments

Comments
 (0)