Skip to content

Commit b93e075

Browse files
committed
copy nodes when tracing list
fix #1841
1 parent 76b8cf3 commit b93e075

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
* `NEW` command `lua.exportDocument` . VSCode will display this command in the right-click menu
55
* `FIX` [#1831]
66
* `FIX` [#1838]
7+
* `FIX` [#1841]
78

89
[#1831]: https://github.com/sumneko/lua-language-server/issues/1831
910
[#1838]: https://github.com/sumneko/lua-language-server/issues/1838
11+
[#1841]: https://github.com/sumneko/lua-language-server/issues/1841
1012

1113
## 3.6.7
1214
`2023-1-20`

script/vm/tracer.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ local lookIntoChild = util.switch()
530530
---@param outNode? vm.node
531531
: call(function (tracer, action, topNode, outNode)
532532
for _, ret in ipairs(action) do
533-
tracer:lookIntoChild(ret, topNode)
533+
tracer:lookIntoChild(ret, topNode:copy())
534534
end
535535
return topNode, outNode
536536
end)
@@ -571,7 +571,7 @@ local lookIntoChild = util.switch()
571571
for i = 2, #action.args do
572572
tracer:lookIntoChild(action.args[i], topNode, topNode:copy())
573573
end
574-
topNode = tracer:lookIntoChild(action.args[1], topNode, topNode:copy())
574+
topNode = tracer:lookIntoChild(action.args[1], topNode:copy(), topNode:copy())
575575
end
576576
tracer:lookIntoChild(action.node, topNode)
577577
tracer:lookIntoChild(action.args, topNode)

test/diagnostics/type-check.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,16 @@ local x
11801180
- 类型 `nil` 无法匹配 `'A'`]])
11811181
end)
11821182

1183+
TEST [[
1184+
---@param v integer
1185+
---@return boolean
1186+
local function is_string(v)
1187+
return type(v) == 'string'
1188+
end
1189+
1190+
print(is_string(3))
1191+
]]
1192+
11831193
config.remove(nil, 'Lua.diagnostics.disable', 'unused-local')
11841194
config.remove(nil, 'Lua.diagnostics.disable', 'unused-function')
11851195
config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global')

0 commit comments

Comments
 (0)