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

multi-line type aliases parse table indexers weirdly #2056

Closed
goldenstein64 opened this issue Apr 6, 2023 · 0 comments
Closed

multi-line type aliases parse table indexers weirdly #2056

goldenstein64 opened this issue Apr 6, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@goldenstein64
Copy link

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Annotations

Expected Behaviour

This type alias should parse as { [1]: string } | number.

---@alias Some
---| { [1]: string }
---| number

local x ---@type Some

print(x)

Actual Behaviour

The type alias can't be parsed and is left as a free Some type.

image

Reproduction steps

  1. Open a file
  2. Write the following text
---@alias Some
---| { [1]: string }
---| number

local x ---@type Some

print(x)
  1. Find that Some can't be parsed and is left as a free type, shown when x is hovered over

Additional Notes

Following the LSP's expected X hovers, it completes itself to an alias like { [1|number]: "type name" }.

---@alias Some
---| { [1]: string }
---| number]: "type name" }

local x ---@type Some

print(x)

It looks like everything after { [1 is ignored and the rest of the line is treated as a comment.

This can be circumvented by putting all the types on one line.

---@alias Some { [1]: string } | number

Log File

lua-language-server.log

@sumneko sumneko added the bug Something isn't working label Apr 24, 2023
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

No branches or pull requests

2 participants