summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lau <tomandfatboy@gmail.com>2024-07-17 15:07:21 +0800
committerTom Lau <tomandfatboy@gmail.com>2024-07-17 15:07:21 +0800
commit97d85952f66b772c255a8856c0cbffa4ef11f1f0 (patch)
tree4106204cef76117885e484c9935f9db9b5a458d8
parentf221eb304e914736f88412b97ed3e1406754a907 (diff)
downloadlua-language-server-97d85952f66b772c255a8856c0cbffa4ef11f1f0.zip
fix: inconsistent type narrow due to outdated node caches of call.args
-rw-r--r--changelog.md1
-rw-r--r--script/vm/compiler.lua6
2 files changed, 7 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index a82efdab..c62510ab 100644
--- a/changelog.md
+++ b/changelog.md
@@ -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`
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index e1b1b43b..f3655123 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -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