Skip to content

Incorrect implicit type alias with | #2498

@superbobry

Description

@superbobry

Describe the Bug

It looks like Pyrefly concludes that A | B is a type alias when both A and B are unknown, e.g.

def test(x, y):
  reveal_type(x | y)  # => type[Any]

This is not particularly helpful, since it could lead to type errors downstream, continuing the example

def f(x: int): ...

def test(x, y):
  f(x | y)

which produces

ERROR Argument `type[Any]` is not assignable to parameter `z` with type `int` in function `f` [bad-argument-type]

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions