Skip to content

String singleton not being coerced through indexer #2965

Description

@PhoenixWhitefire

Given;

type Token = { read Type: "Letter" } | { read Type: "Number" }

local correspond: { read [string]: index<Token, "Type">? } = {
    A = "Letter",
    ["0"] = "Number",
}

, I would expect the code to typecheck without errors. However,

Image

Type errors are reported on both of the values, the "Letter" and "Number" string literals were not inferred to be singletons. Autocomplete seems to work fine though:

Image

Casting the literal to its singleton ("Letter" :: "Letter") mitigates the type error.

Playground

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    analysisThis is an issue related to type inferencebugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions