Skip to content

Commit 8ecec08

Browse files
committed
fix runtime error
fix #2776
1 parent bf69b7c commit 8ecec08

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
## Unreleased
44
<!-- Add all new changes here. They will be moved under a version at release -->
55

6+
## 3.10.1
7+
* `FIX` Runtime error
8+
69
## 3.10.0
710
`2024-8-1`
811
* `NEW` Add postfix snippet for `unpack`

script/vm/compiler.lua

+11-1
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,17 @@ local function matchCall(source)
578578
if call.args then
579579
-- clear node caches of args to allow recomputation with the type narrowed call
580580
for _, arg in ipairs(call.args) do
581-
vm.removeNode(arg)
581+
vm.setNode(arg, vm.createNode(), true)
582+
end
583+
for n in newNode:eachObject() do
584+
if n.type == 'function'
585+
or n.type == 'doc.type.function' then
586+
for i, arg in ipairs(call.args) do
587+
if n.args[i] then
588+
vm.setNode(arg, vm.compileNode(n.args[i]))
589+
end
590+
end
591+
end
582592
end
583593
end
584594
end

test/type_inference/param_match.lua

+24
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,27 @@ local function f(...) end
137137
138138
local <?r?> = f(10)
139139
]]
140+
141+
TEST 'number' [[
142+
---@overload fun(a: 1, c: fun(x: number))
143+
---@overload fun(a: 2, c: fun(x: string))
144+
local function f(...) end
145+
146+
f(1, function (<?a?>) end)
147+
]]
148+
149+
TEST 'string' [[
150+
---@overload fun(a: 1, c: fun(x: number))
151+
---@overload fun(a: 2, c: fun(x: string))
152+
local function f(...) end
153+
154+
f(2, function (<?a?>) end)
155+
]]
156+
157+
TEST 'any' [[
158+
---@overload fun(a: 1)
159+
---@overload fun(a: 2)
160+
local function f(...) end
161+
162+
f(1, function (<?a?>) end)
163+
]]

0 commit comments

Comments
 (0)