File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased
44<!-- Add all new changes here. They will be moved under a version at release -->
5+ * ` FIX ` A regression related to type narrow and generic param introduced since ` v3.10.1 `
56
67## 3.11.1
78` 2024-10-9 `
Original file line number Diff line number Diff line change @@ -630,15 +630,17 @@ local function matchCall(source)
630630 newNode .originNode = myNode
631631 vm .setNode (source , newNode , true )
632632 if call .args then
633- -- clear node caches of args to allow recomputation with the type narrowed call
633+ -- clear existing node caches of args to allow recomputation with the type narrowed call
634634 for _ , arg in ipairs (call .args ) do
635- vm .setNode (arg , vm .createNode (), true )
635+ if vm .getNode (arg ) then
636+ vm .setNode (arg , vm .createNode (), true )
637+ end
636638 end
637639 for n in newNode :eachObject () do
638640 if n .type == ' function'
639641 or n .type == ' doc.type.function' then
640642 for i , arg in ipairs (call .args ) do
641- if n .args [i ] then
643+ if vm . getNode ( arg ) and n .args [i ] then
642644 vm .setNode (arg , vm .compileNode (n .args [i ]))
643645 end
644646 end
Original file line number Diff line number Diff line change @@ -4571,3 +4571,23 @@ else
45714571 local <?b?> = a
45724572end
45734573]]
4574+
4575+ TEST ' nil' [[
4576+ ---@generic T
4577+ ---@param v T
4578+ ---@return T
4579+ ---@overload fun(): nil
4580+ local function f(v) end
4581+
4582+ local <?r?> = f()
4583+ ]]
4584+
4585+ TEST ' string' [[
4586+ ---@generic T
4587+ ---@param v T
4588+ ---@return T
4589+ ---@overload fun(): nil
4590+ local function f(v) end
4591+
4592+ local <?r?> = f('')
4593+ ]]
You can’t perform that action at this time.
0 commit comments