Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Solver] False positive generic type pack mismatch with instantiated type #1620

Open
Hunter1831 opened this issue Jan 19, 2025 · 0 comments
Labels
bug Something isn't working new solver This issue is specific to the new solver.

Comments

@Hunter1831
Copy link

I do not expect calling testA(a) to produce a type error given that the type of argument arg has a generic type pack and should accept a type matching TestA<T...> with any instantiated type.

type TestA<T...> = {
    a: (T...) -> (),
    b: (number, T...) -> ()
}

local function testA<T...>(arg:TestA<T...>) end
local a:TestA<string> = nil::any
testA(a) --Fails " Type pack 'number, string' could not be converted into 'T...' "

This issue also seems to persist with multiple arguments defined for property b as well.

type TestB<T...> = {
    a: (T...) -> (),
    b: (number, boolean, T...) -> ()
}

local function testB<T...>(arg:TestB<T...>) end
local b:TestB<string> = nil::any
testB(b) --Fails " Type pack 'number, boolean, string' could not be converted into 'T...' "

Working Cases

Removing the extra number parameter type for property b does not produce the type error

type TestC<T...> = {
    a: (T...) -> (),
    b: (T...) -> ()
}

local function testC<T...>(arg:TestC<T...>) end
local c:TestC<string> = nil::any
testC(c) -- No type error

Additionally, defining types for the generic type pack in the function definition also does not produce the type error

type TestD<T...> = {
    a: (T...) -> (),
    b: (number, T...) -> ()
}

local function testD(arg:TestD<string>) end
local d:TestD<string> = nil::any
testD(d) -- No type error

Finally, if I remove property a it also does not produce a type error

type TestE<T...> = {
    b: (number, T...) -> ()
}

local function testE<T...>(arg:TestE<T...>) end
local e:TestE<string> = nil::any
testE(e) -- No type error
@Hunter1831 Hunter1831 added the bug Something isn't working label Jan 19, 2025
@aatxe aatxe added the new solver This issue is specific to the new solver. label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new solver This issue is specific to the new solver.
Development

No branches or pull requests

2 participants