Skip to content

@alias not raising expected errors in vscode #1637

@mogsor

Description

@mogsor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions