-
-
Notifications
You must be signed in to change notification settings - Fork 398
Closed
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, Diagnostics/Syntax Checking
Expected Behaviour
---@class TArg
---@field x number
---@field y number
---@class Parent
---@field T TArg
---@class Child : Parent
Child = {}
function Child:init()
self.T = { y = 1, w = 1} --- Expect type warning
end
print(Child.T) -- Expect T to be TArg but got `table`- LuaLS should warn that
{ y = 1, w = 1 }does not matchTArg(sincewis not defined). Child.Tshould retain its inherited type (TArg), not become table.
Actual Behaviour
- LuaLS does not warn about the incorrect structure.
Tin Child is now treated asunknownortable, instead ofTArg.
Reproduction steps
- Paste the code snippet on any editor and check the types
Additional Notes
Possible workarounds
- Manually redeclaring
TinChild
---@class Child : Parent
---@field T TArgThis issue is particularly problematic in large projects where inheritance is heavily used. Manually re-declaring every inherited field just because it gets reassigned is redundant and error-prone.
Log File
No response
Metadata
Metadata
Assignees
Labels
No labels