[New solver] Cant cast type packs "Code is too complex to typecheck!"


if i use types

type TypeA<A... = ()> = {
	value:		TypeB<A...>,
}

type TypeB<A... = ()> = {
	valueA:		TypeB<A...>,
	valueB:		TypeB<A...>,
}

then it does not let me type cast

local a = {} :: TypeA<...number>
local b = a :: TypeA<...string>

here are some more examples


type TypeA<A... = ()> = {
	value:	TypeB<A...>,
}

type TypeB<A... = ()> = {
	valueA:		TypeB<A...>,
	valueB:		TypeB<A...>,
}

local function New<A...>()
	local newA = {} :: TypeA
	local newB = newA :: TypeA<A...>
end

type TypeA<A... = ()> = {
	value:		TypeB<A...>,
}

type TypeB<A... = ()> = {
	valueA:		TypeB<A...>,
	valueB:		TypeB<A...>,
}

local newA = {} :: TypeA<...any>
local newB = newA :: TypeA

type TypeA<A... = ()> = {
	value:		TypeB<A...>,
}

type TypeB<A... = ()> = {
	valueA:		TypeB<A...>,
	valueB:		TypeB<A...>,
}

local function New<T>(value: T) : T
	return {}
end

local a = {} :: TypeA<...any>
local b = New(a) :: TypeA<...string>
5 Likes

i’ve been getting the same error, not sure how to go about a fix since this has been happening since yesterday

Hello! Thank you for the concise reproduction: the new solver should be able to handle basic type casts, agreed, we’ll try to keep you in the loop as we figure out the best way to fix this.

Would you be able to provide a minimal reproduction? “Code too complex” is a broad error: it’s the solver saying “I think I’m spending too much time processing this, I am going to exit so that I don’t spin forever.” Your instance of this might be very different than the examples shown at the top of the thread.