diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2024-07-22 11:01:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-22 11:01:01 +0800 |
commit | 7d06e5573c8188e61516e987b0d796a40f718b05 (patch) | |
tree | 4106204cef76117885e484c9935f9db9b5a458d8 | |
parent | f221eb304e914736f88412b97ed3e1406754a907 (diff) | |
parent | 97d85952f66b772c255a8856c0cbffa4ef11f1f0 (diff) | |
download | lua-language-server-7d06e5573c8188e61516e987b0d796a40f718b05.zip |
Merge pull request #2765 from tomlau10/fix/inconsistent_type_narrow
fix: inconsistent type narrow due to outdated node caches of call.args
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/vm/compiler.lua | 6 |
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 |