Skip to content

[feature] error when == or != is used on values that are incompatible types #721

@yangdanny97

Description

@yangdanny97

Describe the Bug

If someone uses == and != on two values that are completely incompatible types, it will likely work at runtime but is almost certainly a bug.

x: int = 1
y: str = ""

if x == y:
  pass

We should give an error in such cases, with a custom error code so that it can be disabled if necessary.

I was thinking we could just check that is_subset_eq(x, y) or is_subset_eq(y, x) are both false, but there's probably some nuance here in how we want to handle unions.

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions