-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught SyntaxError: Identifier '_alt' has already been declared #2980
Comments
Hi, |
Hello, I can produce this issue by |
That's not a small grammar. |
Hello, i can reproduce this issue with a "medium sized" grammar when trying to update from Antlr 4.8 to 4.9 (Javascript Runtime). Also, it would be great if the documentation could give a concrete example of migration from 4.8 to 4.9 Javascript parser (visitor/listener). |
@XStepien re docs feel free to submit a PR |
could relate to a * and + in the same rule |
alternately please post here the generated code fragment where this happens and the corresponding grammar fragment |
I have this kind of rule:
Where "Calc_ope" is :
Hope this help |
and that rule generates invalid javascript? |
I don't know if it's this rule, but it's related to your comment => "could relate to a * and + in the same rule" I have to do some tests before being able to say which rule generate this issue ( Identifier '_alt' has already been declared ) |
there is no * or + in your rule (I'm referring to ANTLR operators * and +, not characters '*' and '+') |
Ok, sorry for the misunderstanding,I will try to find more information soon |
I'm also seeing this. I can't post the whole grammar for IP reasons, but I do have a few tricky rules with
Hope this helps. It seems plausible since the error is a re-declared variable, and these rules are also recursive. If not I can start deleting/anonymizing names to try to get a minimum reproducible grammar that I can share without exposing proprietary stuff though. |
can you paste the generated fragment causing the trouble? |
ahh... yeah now that I'm looking at the generated code, it's much clearer. The My plain old mathable() rule does, though:
Issue being that
So... it looks like the issue is with non-recursive I was able to fix it by tweaking the generated code to wrap
|
In c87e55b I've switched let _alt... to var ...alt |
That should also be fine.
|
followup: just tested by following the instructions here on your commit. It builds & runs fine again for me. Thanks for the quick response & fix! Not sure what antlr's release schedule is... do you have any estimate on how long it'll be until a patch version gets released with the bug fix? |
Hello, I just upgraded to version 4.9.1 and everything works fine now. Thanks a lot! |
This issue happends on JS runtime target with antlr 4.9, for example:
The generated file
Java9Parser.js
run with this error.The text was updated successfully, but these errors were encountered: