Skip to content

Commit

Permalink
Merge pull request #2765 from tomlau10/fix/inconsistent_type_narrow
Browse files Browse the repository at this point in the history
fix: inconsistent type narrow due to outdated node caches of call.args
  • Loading branch information
sumneko authored Jul 22, 2024
2 parents f221eb3 + 97d8595 commit 7d06e55
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* `NEW` added lua regular expression support for Lua.doc.<scope>Name [#2753](https://github.com/LuaLS/lua-language-server/pull/2753)
* `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)
* `CHG` Change spacing of parameter inlay hints to match other LSPs, like `rust-analyzer`
* `FIX` Inconsistent type narrow behavior of function call args [#2758](https://github.com/LuaLS/lua-language-server/issues/2758)

## 3.9.3
`2024-6-11`
Expand Down
6 changes: 6 additions & 0 deletions script/vm/compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,12 @@ local function matchCall(source)
newNode:removeNode(needRemove)
newNode.originNode = myNode
vm.setNode(source, newNode, true)
if call.args then
-- clear node caches of args to allow recomputation with the type narrowed call
for _, arg in ipairs(call.args) do
vm.removeNode(arg)
end
end
end
end

Expand Down

0 comments on commit 7d06e55

Please sign in to comment.