Skip to content

Warn when if without else discards a value #181

Description

@timfennis

Problem

An if without an else has unit as its false-branch type. If its true branch produces a non-unit value, this can indicate a missing semicolon or an unintended discarded value, but no diagnostic is emitted.

Desired outcome

Add a helpful warning for this pattern, while avoiding false positives for diverging (Never) branches.

Location

ndc_analyser/src/analyser.rs, Expression::If.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions