Skip to content

Explicit instantiation not working with index in return type #2144

@PhoenixWhitefire

Description

@PhoenixWhitefire

Given;

--!strict

type ST = {
    Member1: number,
    Name: string
}

local function access<T>(t, field: T): index<ST, T>
    return t[field]
end

local t: any = {}
local _b = access<<"Member1">>(t, "Member1")

, _b should infer to number. However, the index type function seemingly does not simplify in this case and T is always inferred as any:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions