diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-01-30 20:20:28 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-01-30 20:20:28 +0800 |
commit | b93e0756cc07d9188a8047438f502ff296d5ec66 (patch) | |
tree | a2de65273f09cba6e516c54d513296e82bfb9a62 | |
parent | 76b8cf3236db2efc7f73f3508212d99199b73b52 (diff) | |
download | lua-language-server-b93e0756cc07d9188a8047438f502ff296d5ec66.zip |
copy nodes when tracing list
fix #1841
-rw-r--r-- | changelog.md | 2 | ||||
-rw-r--r-- | script/vm/tracer.lua | 4 | ||||
-rw-r--r-- | test/diagnostics/type-check.lua | 10 |
3 files changed, 14 insertions, 2 deletions
diff --git a/changelog.md b/changelog.md index bf14766f..d9098991 100644 --- a/changelog.md +++ b/changelog.md @@ -4,9 +4,11 @@ * `NEW` command `lua.exportDocument` . VSCode will display this command in the right-click menu * `FIX` [#1831] * `FIX` [#1838] +* `FIX` [#1841] [#1831]: https://github.com/sumneko/lua-language-server/issues/1831 [#1838]: https://github.com/sumneko/lua-language-server/issues/1838 +[#1841]: https://github.com/sumneko/lua-language-server/issues/1841 ## 3.6.7 `2023-1-20` diff --git a/script/vm/tracer.lua b/script/vm/tracer.lua index 823029f0..6ce57d5c 100644 --- a/script/vm/tracer.lua +++ b/script/vm/tracer.lua @@ -530,7 +530,7 @@ local lookIntoChild = util.switch() ---@param outNode? vm.node : call(function (tracer, action, topNode, outNode) for _, ret in ipairs(action) do - tracer:lookIntoChild(ret, topNode) + tracer:lookIntoChild(ret, topNode:copy()) end return topNode, outNode end) @@ -571,7 +571,7 @@ local lookIntoChild = util.switch() for i = 2, #action.args do tracer:lookIntoChild(action.args[i], topNode, topNode:copy()) end - topNode = tracer:lookIntoChild(action.args[1], topNode, topNode:copy()) + topNode = tracer:lookIntoChild(action.args[1], topNode:copy(), topNode:copy()) end tracer:lookIntoChild(action.node, topNode) tracer:lookIntoChild(action.args, topNode) diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua index 7882df69..8f3d6936 100644 --- a/test/diagnostics/type-check.lua +++ b/test/diagnostics/type-check.lua @@ -1180,6 +1180,16 @@ local x - 类型 `nil` 无法匹配 `'A'`]]) end) +TEST [[ +---@param v integer +---@return boolean +local function is_string(v) + return type(v) == 'string' +end + +print(is_string(3)) +]] + config.remove(nil, 'Lua.diagnostics.disable', 'unused-local') config.remove(nil, 'Lua.diagnostics.disable', 'unused-function') config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global') |