Skip to content

chore: #853 — triage 22 unreachable pattern/expression warnings#1057

Merged
proggeramlug merged 2 commits into
mainfrom
worktree-fix-853-unreachable-patterns
May 19, 2026
Merged

chore: #853 — triage 22 unreachable pattern/expression warnings#1057
proggeramlug merged 2 commits into
mainfrom
worktree-fix-853-unreachable-patterns

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

Summary

Closes #853. Walked the site list per-warning and put each in one of three buckets.

Real bugs / dead duplicates (deleted)

Site What was wrong
crates/perry-codegen-js/src/emit.rs "textSetColor" Two arms; the first mapped to perry_ui_set_foreground (never existed as FFI). Latent codegen bug — the canonical perry_ui_text_set_color mapping was being shadowed.
crates/perry-runtime/src/object.rs (two arms) is_valid_obj_ptr guard sat after an unconditional return. Dead.
crates/perry-hir/src/analysis.rs Expr::Os* variants enumerated twice.
crates/perry-hir/src/lower/expr_call.rs Map-only entries/keys/values arms shadowed by the shared #542/#543 arm covering Map+Set+Array.
crates/perry-codegen-js/src/emit.rs StringFromCodePoint / StringAt / StringCodePointAt duplicated.
crates/perry-codegen/src/collectors.rs Expr::ErrorNew(None) shadowed by earlier ErrorNew(opt).
crates/perry-codegen/src/type_analysis.rs JsonStringifyFull(..) enumerated twice.
crates/perry-transform/src/deforest.rs PropertyUpdate duplicated.
crates/perry-hir/src/lower/expr_assign.rs Catch-all after exhaustive AssignOp. New SWC variants now fail compile rather than land in a generic error path.
crates/perry-runtime/src/fs.rs js_throw is -> !; trailing f64::from_bits was dead.
crates/perry-codegen/src/expr.rs Inline-fcmp block kept "as documentation" but rotted into unreachable-statement noise.

Forward-compat safety nets (#[allow(unreachable_patterns)] + comment)

For variants of #[non_exhaustive] upstream enums and HIR types: kept the catch-all so future variants don't silently drop, but annotated to silence the lint. Sites: lower.rs (Decl + UnaryOp), lower_decl.rs (Stmt), codegen/stmt.rs (HIR Stmt), publish.rs (OutputFormat).

Test plan

  • cargo build --release --workspace --exclude perry-ui-… — zero unreachable_* warnings remaining
  • cargo test --release -p perry-runtime --lib — 264 pass
  • cargo test --release -p perry-hir — 88 + 11 + 40 pass
  • cargo test --release -p perry-codegen — 31 + 4 pass

Walked the issue's site list per-warning. Each site fell into one of
three categories; treatment chosen per category:

**Real bugs / dead duplicates (deleted)**

- `crates/perry-codegen-js/src/emit.rs` — `"textSetColor"` had two arms;
  the earlier one mapped to `perry_ui_set_foreground`, which has never
  existed as an FFI symbol. Deleted the dead first arm so the canonical
  `perry_ui_text_set_color` mapping takes effect. Latent bug.
- `crates/perry-runtime/src/object.rs` — two arms had an `is_valid_obj_ptr`
  guard sitting AFTER an unconditional return. Both removed.
- `crates/perry-hir/src/analysis.rs` — `Expr::Os*` variants enumerated
  twice in `collect_assigned_locals_expr`. Second arm removed.
- `crates/perry-hir/src/lower/expr_call.rs` — the Map-only
  `entries`/`keys`/`values` arms had been shadowed by the shared
  arm added in #542/#543 covering Map+Set+Array. Removed.
- `crates/perry-codegen-js/src/emit.rs` — `StringFromCodePoint`/
  `StringAt`/`StringCodePointAt` were each handled twice. Duplicates removed.
- `crates/perry-codegen/src/collectors.rs` — `Expr::ErrorNew(None)`
  shadowed by an earlier `ErrorNew(opt)` arm. Removed.
- `crates/perry-codegen/src/type_analysis.rs` — `JsonStringifyFull(..)`
  enumerated twice. Removed second occurrence.
- `crates/perry-transform/src/deforest.rs` — `PropertyUpdate` arm
  duplicated. Removed second.
- `crates/perry-hir/src/lower/expr_assign.rs` — catch-all `_ => Err`
  after exhaustive AssignOp variants. Removed; new SWC variants will now
  fail compile rather than land in a generic error path.
- `crates/perry-runtime/src/fs.rs` — `js_throw` is `-> !`; the trailing
  `f64::from_bits(TAG_UNDEFINED)` was dead. Tail-called the throw instead.
- `crates/perry-codegen/src/expr.rs` — block of fcmp inline code after
  `return Ok(...)`. The block was kept "as documentation" but rotted into
  unreachable-statement noise; the explanatory comment above the return
  already covers the intent.

**Forward-compat safety nets (#[allow(unreachable_patterns)] + comment)**

- `crates/perry-hir/src/lower.rs` — two arms (Decl, UnaryOp) where SWC
  marks the upstream enum `#[non_exhaustive]`. Kept the catch-all so
  future SWC variants don't silently drop.
- `crates/perry-hir/src/lower_decl.rs` — same shape for `ast::Stmt`.
- `crates/perry-codegen/src/stmt.rs` — same shape for `perry_hir::Stmt`,
  so HIR additions land as a clear compile diagnostic.
- `crates/perry/src/commands/publish.rs` — `OutputFormat` catch-all.

All 21 unreachable warnings now silenced. `cargo test --release` passes
for perry-runtime (264), perry-hir (88+11+40), perry-codegen (31+4).
@proggeramlug proggeramlug merged commit c96f8c9 into main May 19, 2026
9 checks passed
@proggeramlug proggeramlug deleted the worktree-fix-853-unreachable-patterns branch May 19, 2026 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: triage unreachable pattern/expression warnings (22)

1 participant