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

Does not support leading & #311

Open
iamawatermelo opened this issue Jul 25, 2024 · 2 comments
Open

Does not support leading & #311

iamawatermelo opened this issue Jul 25, 2024 · 2 comments

Comments

@iamawatermelo
Copy link

From JohnnyMorganz/StyLua#877:

local f: & number & string = "hi"

This is valid Luau code:

image

StyLua cannot format it, though:

sarah@localhost ~/project (main) [2]> StyLua example.luau
error: could not format file example.luau: error parsing: error occurred while creating ast: unexpected token `&`. (starting from line 1, character 10 and ending on line 1, character 11)
additional information: expected type after colon
sarah@localhost ~/project (main) [2]> StyLua --version
stylua 0.20.0
sarah@localhost ~/project (main)>

StyLua was installed from aftman.

The issue appears to be that full-moon cannot parse it, so StyLua fails.

@Kampfkarren
Copy link
Owner

Fixed by #306

@jeparlefrancais
Copy link
Contributor

jeparlefrancais commented Oct 14, 2024

When the leading & or | are used in some specific cases, they don't parse. Here are the cases I found so far

-- in function return types
type Fn = () -> & A & B
local function oof():  & A & B end

-- in generic parameters
type A = Generic<&boolean & string>

-- in variadic type packs
type Fn = (...&boolean & string) -> ()

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants