Skip to content

Try eliminating ~AlwaysFalsy and ~AlwaysTruthy from intersections if they don't immediately simplify out #2233

@carljm

Description

@carljm

They are rarely useful (this is a hypothesis -- to be confirmed or refuted by ecosystem tests), they make our displayed types more complex/confusing, and their tendency to preserve intersections instead of simpler types can cause other issues (e.g. most recently #2200). Simplifying them out may improve performance due to more simple types instead of intersections (again a hypothesis to check on an actual PR.)

The easy approach here (good for a prototype PR to check the performance and ecosystem impact) would be to just strip them out in IntersectionBuilder::build.

If we decide we want to do this, the better approach might be to remove them entirely as Type variants, and replace with Type::remove_always_truthy and Type::remove_always_falsy transformers which can be used in type narrowing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions