Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased
<!-- Add all new changes here. They will be moved under a version at release -->
* `FIX` Unannotated functions that return a generic class instance (e.g. `Box<string>`) returned from a call no longer show `|unknown` in their inferred return type

## 3.19.2
`2026-10-13`
Expand Down
4 changes: 4 additions & 0 deletions script/vm/compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2248,6 +2248,10 @@ local compilerSwitch = util.switch()
end
goto CONTINUE
end
if n.type == 'doc.type.sign' then
hasKnownType = true
break
end
hasUnknownType = true
::CONTINUE::
end
Expand Down
29 changes: 23 additions & 6 deletions test/type_inference/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var = y

TEST 'any' [[
function f(<?x?>)

end
]]

Expand Down Expand Up @@ -1536,7 +1536,7 @@ local mt = {}
function mt:loop(callback) end

mt:loop(function (<?i?>)

end)
]]

Expand Down Expand Up @@ -2684,7 +2684,7 @@ return function ()
if not t then
return
end

print(<?t?>)
end
]]
Expand All @@ -2697,7 +2697,7 @@ f(function ()
if not t then
return
end

print(<?t?>)
end)
]]
Expand Down Expand Up @@ -3439,7 +3439,7 @@ local n
---@type string
local s

local <?test?> = t[n]
local <?test?> = t[n]
local test2 = t[s] --test and test2 are unknow
]]

Expand All @@ -3452,7 +3452,7 @@ local n
---@type string
local s

local test = t[n]
local test = t[n]
local <?test2?> = t[s] --test and test2 are unknow
]]

Expand Down Expand Up @@ -5278,3 +5278,20 @@ local myClass

local <?result?> = myClass:pass(42)
]]

TEST 'Box<string>' [[
---@class Box<T>
---@field value T

---@return Box<string>
function make_box()
return { value = "x" }
end

function wrap()
local b = make_box()
return b
end

local <?r?> = wrap()
]]
Loading