Skip to content

Commit

Permalink
copy nodes when tracing list
Browse files Browse the repository at this point in the history
fix #1841
  • Loading branch information
sumneko committed Jan 30, 2023
1 parent 76b8cf3 commit b93e075
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
4 changes: 2 additions & 2 deletions script/vm/tracer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions test/diagnostics/type-check.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit b93e075

Please sign in to comment.