Skip to content

Commit 2da06ee

Browse files
committed
FIX Incorrect type check in some case
1 parent 43ad969 commit 2da06ee

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
## Unreleased
44
<!-- Add all new changes here. They will be moved under a version at release -->
55

6+
## 3.13.1
7+
`2024-11-13`
8+
* `FIX` Incorrect type check in some case
9+
610
## 3.13.0
711
`2024-11-13`
812
* `NEW` Setting: `Lua.type.inferTableSize`: A Small Table array can be infered

script/vm/type.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,10 @@ function vm.isSubType(uri, child, parent, mark, errs)
587587
and not mark[childName] then
588588
mark[childName] = true
589589
if vm.isSubType(uri, parentName, childName, mark) then
590+
mark[childName] = nil
590591
return true
591592
end
593+
mark[childName] = nil
592594
end
593595

594596
if errs then

test/diagnostics/param-type-mismatch.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,4 +364,24 @@ local i
364364
f(i)
365365
]]
366366

367+
TEST [[
368+
---@class A: integer
369+
370+
---@param a A
371+
local function f(a) end
372+
373+
local t = {
374+
{ int = 123 },
375+
{ int = 456 },
376+
{ int = 789 },
377+
}
378+
379+
---@type integer
380+
local i
381+
382+
local k = t[i].int
383+
384+
f(k)
385+
]]
386+
367387
config.set(nil, 'Lua.type.checkTableShape', false)

0 commit comments

Comments
 (0)