Skip to content
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

Parse error with goto as variable name for non-Lua5.2 #190

Closed
JohnnyMorganz opened this issue Jul 19, 2021 · 3 comments · Fixed by #199
Closed

Parse error with goto as variable name for non-Lua5.2 #190

JohnnyMorganz opened this issue Jul 19, 2021 · 3 comments · Fixed by #199
Labels
bug Something isn't working

Comments

@JohnnyMorganz
Copy link
Collaborator

In non-Lua5.2 code, using goto as a variable name leads to a parsing error.
It seems to be stemming from

// TODO: This only is valid in Lua 5.2
Goto => "goto",
where goto is a restricted symbol (for Lua 5.2+), but this is leaking into the parsing for 5.1/Luau.

Reported in JohnnyMorganz/StyLua#229

@JohnnyMorganz JohnnyMorganz changed the title goto not allowed in variable name for non-Lua5.2 Parse error with goto as variable name for non-Lua5.2 Jul 19, 2021
@Kampfkarren Kampfkarren added the bug Something isn't working label Jul 20, 2021
@Kampfkarren
Copy link
Owner

Out of curiosity, does local goto = 1 work in Lua 5.2 for backwards compatibility? If not this becomes a real pain considering we only support Lua 5.2 as a feature, and not as a toggleable.

@JohnnyMorganz
Copy link
Collaborator Author

Tested it using https://www.lua.org/cgi-bin/demo since I don't have a Lua 5.2 installation to hand, and local goto = 1 is not allowed. It is also mentioned as a reserved keyword https://www.lua.org/manual/5.2/manual.html#3.1.

I guess this can probably be fixed, but we are breaking the additive nature of rust features - doesn't look like there's any great solution here, other than waiting for pluggable parsing

@Kampfkarren
Copy link
Owner

God that is annoying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants