Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Lua 5.2] Parsing error when label is used after break #861

Open
raiguard opened this issue May 30, 2024 · 1 comment
Open

[Lua 5.2] Parsing error when label is used after break #861

raiguard opened this issue May 30, 2024 · 1 comment
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@raiguard
Copy link

Attempting to format this valid Lua code:

for i = 1, 10 do
  if i < 8 then
    print(i)
    goto continue
  end
  break
  ::continue::
end

gives the following error:

error: could not format from stdin: failed to format from stdin: error parsing: error occurred while creating ast: unexpected token `::`. (starting from line 52, character 5 and ending on line 52, character 7)
additional information: expected 'end'

This is likely a full-moon issue rather than something specific to stylua, but I don't want to jump the gun just in case.

@JohnnyMorganz
Copy link
Owner

This is the same issue as #402

The stylua release binaries are built with all feature flags enabled, and the Luau type assertion syntax conflicts with Lua 5.2 label syntax.

You can use cargo to build a binary with only lua52 enabled and that should work. Hopefully in the next major release we will have runtime configurable syntax selection

@JohnnyMorganz JohnnyMorganz added bug Something isn't working duplicate This issue or pull request already exists labels Jun 1, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants