Skip to content

Commit 7d06e55

Browse files
authored
Merge pull request #2765 from tomlau10/fix/inconsistent_type_narrow
fix: inconsistent type narrow due to outdated node caches of call.args
2 parents f221eb3 + 97d8595 commit 7d06e55

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* `NEW` added lua regular expression support for Lua.doc.<scope>Name [#2753](https://github.com/LuaLS/lua-language-server/pull/2753)
1313
* `FIX` Bad triggering of the `inject-field` diagnostic, when the fields are declared at the creation of the object [#2746](https://github.com/LuaLS/lua-language-server/issues/2746)
1414
* `CHG` Change spacing of parameter inlay hints to match other LSPs, like `rust-analyzer`
15+
* `FIX` Inconsistent type narrow behavior of function call args [#2758](https://github.com/LuaLS/lua-language-server/issues/2758)
1516

1617
## 3.9.3
1718
`2024-6-11`

script/vm/compiler.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,12 @@ local function matchCall(source)
575575
newNode:removeNode(needRemove)
576576
newNode.originNode = myNode
577577
vm.setNode(source, newNode, true)
578+
if call.args then
579+
-- clear node caches of args to allow recomputation with the type narrowed call
580+
for _, arg in ipairs(call.args) do
581+
vm.removeNode(arg)
582+
end
583+
end
578584
end
579585
end
580586

0 commit comments

Comments
 (0)