Skip to content

Commit 48a608d

Browse files
committed
fix #1902
1 parent 457931e commit 48a608d

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
* `FIX` [#1887]
77
* `FIX` [#1889]
88
* `FIX` [#1895]
9+
* `FIX` [#1902]
910

1011
[#1886]: https://github.com/LuaLS/lua-language-server/issues/1886
1112
[#1887]: https://github.com/LuaLS/lua-language-server/issues/1887
1213
[#1889]: https://github.com/LuaLS/lua-language-server/issues/1889
1314
[#1895]: https://github.com/LuaLS/lua-language-server/issues/1895
15+
[#1902]: https://github.com/LuaLS/lua-language-server/issues/1902
1416

1517
## 3.6.10
1618
`2023-2-7`

script/vm/tracer.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,8 @@ local lookIntoChild = util.switch()
641641
and handler.args[1]
642642
and tracer.getMap[handler.args[1]] then
643643
-- if type(x) == 'string' then
644-
tracer:lookIntoChild(handler, topNode:copy())
644+
tracer:lookIntoChild(handler, topNode)
645+
topNode = topNode:copy()
645646
if action.op.type == '==' then
646647
topNode:narrow(tracer.uri, checker[1])
647648
if outNode then

test/diagnostics/type-check.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,16 @@ local function some_fn(some_param) return end
12011201
some_fn { { "test" } } -- <- diagnostic: "Cannot assign `table` to `string`."
12021202
]]
12031203

1204+
TEST [[
1205+
---@param p integer|string
1206+
local function get_val(p)
1207+
local is_number = type(p) == 'number'
1208+
return is_number and p or p
1209+
end
1210+
1211+
get_val('hi')
1212+
]]
1213+
12041214
config.remove(nil, 'Lua.diagnostics.disable', 'unused-local')
12051215
config.remove(nil, 'Lua.diagnostics.disable', 'unused-function')
12061216
config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global')

0 commit comments

Comments
 (0)