Skip to content

feat: Ternary operator support in simple non-comptime cases #2530

Description

@iwoplaza

If we can ensure that both branches of a ternary operator are side-effect free with heuristics, we can emit a select() call instead.

Maybe the heuristic essentially boils down to "Is there a call expression in here?"

Note

We can also do proper side-effect analysis to allow side-effect free functions to be used in ternary operators. We can store this as another kind of flag on the snippet type.

If there are more cases where this sort of analysis might be useful, we can prioritize this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions