Skip to content

chore: triage unreachable pattern/expression warnings (22) #853

@TheHypnoo

Description

@TheHypnoo

There are 22 reachability warnings flagged by cargo build --release that need per-site review:

  • 21 × unreachable pattern
  • 1 × unreachable expression (plus a few unreachable statement mixed in)

Why per-site review

Each unreachable pattern is one of two things:

  1. A redundant catch-all after the previous arms already cover all cases → safe to delete.
  2. A real bug where an earlier arm absorbs cases that were meant to land in this branch.

Without reading each case, removing them risks discarding intentional fall-throughs or silently changing behavior. unreachable expression warnings (code after return/throw) have the same flavor.

Sites

crates/perry-codegen-js/src/emit.rs:2675
crates/perry-codegen-js/src/emit.rs:2680
crates/perry-codegen-js/src/emit.rs:2686
crates/perry-codegen-js/src/emit.rs:3414
crates/perry-codegen/src/collectors.rs:5156
crates/perry-codegen/src/expr.rs:7283
crates/perry-codegen/src/stmt.rs:1105
crates/perry-codegen/src/type_analysis.rs:902
crates/perry-hir/src/analysis.rs:1039
crates/perry-hir/src/lower.rs:6478
crates/perry-hir/src/lower.rs:8270
crates/perry-hir/src/lower/expr_assign.rs:226
crates/perry-hir/src/lower/expr_call.rs:4095
crates/perry-hir/src/lower/expr_call.rs:4105
crates/perry-hir/src/lower/expr_call.rs:4115
crates/perry-hir/src/lower_decl.rs:5340
crates/perry-jsruntime/src/modules.rs:1175
crates/perry-runtime/src/fs.rs:797
crates/perry-runtime/src/object.rs:6173
crates/perry-runtime/src/object.rs:6462
crates/perry-transform/src/deforest.rs:1525
crates/perry/src/commands/publish.rs:2469

Full list reproducible via:

cargo build --release 2>&1 | grep -A1 "unreachable"

How to approach

  1. For each site, look at the preceding match arms.
  2. Decide:
    • If the wildcard truly is unreachable → delete it (and the warning).
    • If an earlier arm absorbs cases that should have landed here → fix the earlier arm, then the wildcard becomes reachable again.
  3. Run the gap-test suite (./run_parity_tests.sh) after changes to catch behavioral regressions.

Context

Carved out of the warning-cleanup PR (chore: reduce compile warnings 325 → 125). The mechanical fixes there were guaranteed-no-op; these warnings require judgment per site.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions