Variadic Arguments Incompatible with Variadic Generic Type

I noticed a strange warning relating to function parameters and variadic generics. I recreated the scenario using an example type and function to see if I was doing something wrong, and the warning still appeared. I’ve tried casting the Object variable and that didn’t work either.

I’m using the typechecker beta.

Here’s the error on line 15:

Type Error: Type ‘Example<T…>’ could not be converted into ‘Example’; this is because accessing Method, takes a tail of T... and accessing Method, takes the portion of the type pack starting at index 0 to the endstring, and T... is not exactly string

Here’s the source code:

--!strict

type Example<T...> = {
	Method: (T...) -> ();
}

local function CreateExample<T...>(Method: (T...) -> ()): Example<T...>
	local self = {}
	
	self.Method = Method
	
	return self
end

local Object: Example<string> = CreateExample(function(a: string)
	print(a)
end)

Object.Method("Hello World!")

A screenshot just in case

Hello! Thank you for the bug report. Agreed, the code as you submitted ought to work. We’ll take a look at this when we can, and will try to keep you in the loop as a fix goes out.

1 Like

Hello again! Checking in to say I believe we’ve rolled out a fix for this, the following code:

--!strict

type Example<T...> = {
	Method: (T...) -> ();
}

local function CreateExample<T...>(Method: (T...) -> ()): Example<T...>
	local self = {}

	self.Method = Method

	return self
end

local Object: Example<string> = CreateExample(function(a: string)
	print(a)
end)

Object.Method("Hello World!")

… no longer has errors. If you’re still running into new solver issues, please let us know!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.