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'.
As of version 0.651, passing a value to a function where the type of the parameter is
index<T>
andT
is a generic type fails, reducing the parameter tonever
. In this repro, replacing all occurrances ofT
in the functionset
with'a'
results in the parameter being inferred correctly, therefore it should work as a generic parameter as well.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 whenT
is replaced with'a'
.