diff --git a/changelog.md b/changelog.md index 611937936..94cf4a1c2 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,9 @@ ## Unreleased +## 3.10.1 +* `FIX` Runtime error + ## 3.10.0 `2024-8-1` * `NEW` Add postfix snippet for `unpack` diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index f3655123f..543904502 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -578,7 +578,17 @@ local function matchCall(source) if call.args then -- clear node caches of args to allow recomputation with the type narrowed call for _, arg in ipairs(call.args) do - vm.removeNode(arg) + vm.setNode(arg, vm.createNode(), true) + end + for n in newNode:eachObject() do + if n.type == 'function' + or n.type == 'doc.type.function' then + for i, arg in ipairs(call.args) do + if n.args[i] then + vm.setNode(arg, vm.compileNode(n.args[i])) + end + end + end end end end diff --git a/test/type_inference/param_match.lua b/test/type_inference/param_match.lua index 8ead05ef3..1079e4332 100644 --- a/test/type_inference/param_match.lua +++ b/test/type_inference/param_match.lua @@ -137,3 +137,27 @@ local function f(...) end local = f(10) ]] + +TEST 'number' [[ +---@overload fun(a: 1, c: fun(x: number)) +---@overload fun(a: 2, c: fun(x: string)) +local function f(...) end + +f(1, function () end) +]] + +TEST 'string' [[ +---@overload fun(a: 1, c: fun(x: number)) +---@overload fun(a: 2, c: fun(x: string)) +local function f(...) end + +f(2, function () end) +]] + +TEST 'any' [[ +---@overload fun(a: 1) +---@overload fun(a: 2) +local function f(...) end + +f(1, function () end) +]]