LuaLS / LuaLS/lua-language-server
assign-type-mismatch not emitted when assigning a class to an array
Open
Nobody has claimed this yet.
feat/type check
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
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?
Type Checking
Expected Behaviour
---@class a
local a = {}
---@class b
local b = {}
---@type a[]
local c = {
a,
b, // assign-type-mismatch emitted here
}
c = "" // assign-type-mismatch emitted here
c = b // assign-type-mismatch emitted here
c = a // assign-type-mismatch emitted here
Actual Behaviour
---@class a
local a = {}
---@class b
local b = {}
---@type a[]
local c = {
a,
b, // assign-type-mismatch is correctly emitted here
}
c = "" // assign-type-mismatch is correctly emitted here
c = b // No assign-type-mismatch is emitted here. I would expect it to be emitted here.
c = a // No assign-type-mismatch is emitted here. I would expect it to be emitted here.
Reproduction steps
.luarc.json:
{
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"runtime.version": "Lua 5.1"
}
Additional Notes
No response
Log File
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report using the supplied .luarc.json and Lua snippet, checking the three assignment cases involving the a[] annotation. Trace the type-checking path responsible for assign-type-mismatch diagnostics and compare class assignments with the already-diagnosed string assignment and array literal element. Done means mismatched class assignments to the array are diagnosed without changing the existing diagnostics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100