Skip to content

index<T> where T is a generic type of a function reduces to never in new solver strict mode #1524

@nothing1649

Description

@nothing1649

As of version 0.651, passing a value to a function where the type of the parameter is index<T> and T is a generic type fails, reducing the parameter to never.
In this repro, replacing all occurrances of T in the function set with 'a' results in the parameter being inferred correctly, therefore it should work as a generic parameter as well.

--!strict
--!optimize 2
local t: {
	read a: number,
	read b: string,
	read c: buffer
} = nil::never

local function set<T>(i:T, v:index<typeof(t), T>): () end

--note: the cast to 'a' is a workaround for an unrelated issue, see #1483 
set('a'::'a', 1) --Type 'number' could not be converted into 'never'

Expected behaviour

The second parameter is inferred as the type of the value at the index of the first parameter (in this case number), matching the behaviour of when T is replaced with 'a'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnew solverThis issue is specific to the new solver.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions