chore: #853 — triage 22 unreachable pattern/expression warnings#1057
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #853. Walked the site list per-warning and put each in one of three buckets.
Real bugs / dead duplicates (deleted)
crates/perry-codegen-js/src/emit.rs"textSetColor"perry_ui_set_foreground(never existed as FFI). Latent codegen bug — the canonicalperry_ui_text_set_colormapping was being shadowed.crates/perry-runtime/src/object.rs(two arms)is_valid_obj_ptrguard sat after an unconditional return. Dead.crates/perry-hir/src/analysis.rsExpr::Os*variants enumerated twice.crates/perry-hir/src/lower/expr_call.rsentries/keys/valuesarms shadowed by the shared #542/#543 arm covering Map+Set+Array.crates/perry-codegen-js/src/emit.rsStringFromCodePoint/StringAt/StringCodePointAtduplicated.crates/perry-codegen/src/collectors.rsExpr::ErrorNew(None)shadowed by earlierErrorNew(opt).crates/perry-codegen/src/type_analysis.rsJsonStringifyFull(..)enumerated twice.crates/perry-transform/src/deforest.rsPropertyUpdateduplicated.crates/perry-hir/src/lower/expr_assign.rsAssignOp. New SWC variants now fail compile rather than land in a generic error path.crates/perry-runtime/src/fs.rsjs_throwis-> !; trailingf64::from_bitswas dead.crates/perry-codegen/src/expr.rsForward-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-…— zerounreachable_*warnings remainingcargo test --release -p perry-runtime --lib— 264 passcargo test --release -p perry-hir— 88 + 11 + 40 passcargo test --release -p perry-codegen— 31 + 4 pass