Skip to content

Literal promotion is not performed for generic calls #1357

@ibraheemdev

Description

@ibraheemdev

For example, on main:

def lst[T](x: T) -> list[T]:
    return [x]

a = lst(1)
reveal_type(a)  # revealed: list[Literal[1]]

We currently perform literal promotion when inferring the list expression, i.e. before specialization. We may need a second literal promotion step during specialization for this to work, similar to what we do for generic constructors.

Metadata

Metadata

Assignees

Labels

bidirectional inferenceInference of types that takes into account the context of a declared type or expected type

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions