[New solver] Type 'nil' could not be converted into 'Type?' if Type uses generics

if i use <P...> or <P> in my type i get strange type errors

here is a example
also added child to show that it effects other types that point to the type that uses generics

export type Parent = {
	-- if you remove <P...> it starts working
	Func1:<P...>		(self: Parent, value: boolean, P...) -> (Parent?),
	Func2:				(self: Parent, value: boolean) -> (Parent?),
}

export type Child = {
	Parent:			Parent, -- if this is here it effects the child as well
	Func:			(self: Child) -> (Child?),
}

local Parent = {}	:: Parent
local Child = {}	:: Child

function Parent:Func1(value, ...)
	if value then return self else return nil end
end

function Parent:Func2(value)
	if value then return self else return nil end
end

function Child:Func(value)
	if value then return self else return nil end
end

Hi there, thanks for the report! I don’t have an immediate guess as to the root cause right now, but I’ll look into it.

2 Likes

Hello! Sorry for the wait here, but I believe we’ve rolled out a fix to address this, the following code:

--!strict
export type Parent = {
	-- if you remove <P...> it starts working
	Func1:<P...>		(self: Parent, value: boolean, P...) -> (Parent?),
	Func2:				(self: Parent, value: boolean) -> (Parent?),
}

export type Child = {
	Parent:			Parent, -- if this is here it effects the child as well
	Func:			(self: Child) -> (Child?),
}

local Parent = {}	:: Parent
local Child = {}	:: Child

function Parent:Func1(value, ...)
	if value then return self else return nil end
end

function Parent:Func2(value)
	if value then return self else return nil end
end

function Child:Func(value)
	if value then return self else return nil end
end

… no longer errors! Though the Child:Func line probably ought to. Anyhow, I’m considering this issue fixed, please let me know if you encounter any further issues!

1 Like