-
-
Notifications
You must be signed in to change notification settings - Fork 403
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
In the below I am trying to set the type of the variable i in a for loop. the on-hover looks correct when done with @type, but it fails to evaluate correctly when used, however the cast works as expected.
---@class integerA : integer
local list = {} ---@type table<integerA, table>
---@type integerA
for i = 1, 10 do
list[i] = {} --- This `i` says its type integerA, however the line gives an error of "Can not infer type. LuaDiagnostics.(no-unknown)"
end
for i = 1, 10 do
---@cast i integerA
list[i] = {}
end
I believe the @type method is "better" than cast as it feels a more natural way to define its type, rather than forcing the variable to be viewed as having a set type with cast.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working