Skip to content

Commit

Permalink
FIX Incorrect type check in some case
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Nov 13, 2024
1 parent 43ad969 commit 2da06ee
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
## Unreleased
<!-- Add all new changes here. They will be moved under a version at release -->

## 3.13.1
`2024-11-13`
* `FIX` Incorrect type check in some case

## 3.13.0
`2024-11-13`
* `NEW` Setting: `Lua.type.inferTableSize`: A Small Table array can be infered
Expand Down
2 changes: 2 additions & 0 deletions script/vm/type.lua
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,10 @@ function vm.isSubType(uri, child, parent, mark, errs)
and not mark[childName] then
mark[childName] = true
if vm.isSubType(uri, parentName, childName, mark) then
mark[childName] = nil
return true
end
mark[childName] = nil
end

if errs then
Expand Down
20 changes: 20 additions & 0 deletions test/diagnostics/param-type-mismatch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,24 @@ local i
f(i)
]]

TEST [[
---@class A: integer
---@param a A
local function f(a) end
local t = {
{ int = 123 },
{ int = 456 },
{ int = 789 },
}
---@type integer
local i
local k = t[i].int
f(k)
]]

config.set(nil, 'Lua.type.checkTableShape', false)

0 comments on commit 2da06ee

Please sign in to comment.