Skip to content

@alias not raising expected errors in vscode #1637

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

Closed
mogsor opened this issue Oct 16, 2022 · 0 comments
Closed

@alias not raising expected errors in vscode #1637

mogsor opened this issue Oct 16, 2022 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@mogsor
Copy link

mogsor commented Oct 16, 2022

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Linux

What is the issue affecting?

Annotations

Expected Behaviour

I expected this code would produce an assignment error, since it's assigning an integer to a boolean-typed variable:

---@alias test boolean

---@type test
local test = 4 -- error expected (assign-type-mismatch)

Actual Behaviour

But no error is raised:

---@alias test boolean

---@type test
local test = 4 -- no error
test = "four"
test = false
test = 4
-- no errors

Reproduction steps

Create a new lua file, assign an alias, then assign a mismatched type to it.

Additional Notes

This is with the Lua extension at mostly default settings: only formatting and telemetry are disabled. vscode is version 1.72.2, and the lua extension is version 3.5.6.

The language server is definitely running; in the same file, the following assignments:

---@type boolean
local test_two = 4 -- error (assign-type-mismatch)

---@type non_existent_alias -- error (undefined-doc-name)
local test_three = 4 -- error (assign-type-mismatch)

Produce these errors:

image

Interestingly, the server does seem to know what type the variable should be, as it shows it correctly in the autocomplete suggestion:

image

Apologies if this is intended behaviour or a known issue.

Log File

file_home_mogsor_public_tts.log

@sumneko sumneko added the bug Something isn't working label Oct 17, 2022
@sumneko sumneko added this to the 3.6.0 milestone Oct 17, 2022
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