From 1a4718d3e0204da51594cb084aa13d2c66b918f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralph=20K=C3=BCpper?= Date: Mon, 31 Aug 2026 18:32:24 +0200 Subject: [PATCH] refactor(codegen): defuse the guarded-wildcard trap in accumulator_rhs_is_numeric MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `_ if offset_reads_inlined =>` was a guarded wildcard: any match arm placed after it was reachable only while the flag was false, with no possible compiler warning since reachability depends on the runtime guard. #9303's first cut added an index form below it and verified as a complete no-op in the range tier while passing every flag-false test. Semantically identical — the guard moves into the body of a single unguarded catch-all, and future index forms extend that body where the same tests cover both flag states. Two-liner agreed with the #9303 author, who rebases on it. --- .../src/stmt/stable_packed_accumulator.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/perry-codegen/src/stmt/stable_packed_accumulator.rs b/crates/perry-codegen/src/stmt/stable_packed_accumulator.rs index 0bc7abdec6..682bbc86c7 100644 --- a/crates/perry-codegen/src/stmt/stable_packed_accumulator.rs +++ b/crates/perry-codegen/src/stmt/stable_packed_accumulator.rs @@ -67,11 +67,18 @@ fn accumulator_rhs_is_numeric( // expression lowers to a tag-test diamond over // `js_dynamic_string_or_number_add` — the same cost #9060 and // #9091 removed for the bare-counter form. - _ if offset_reads_inlined => { - crate::expr::packed_f64_loop_index_parts(index) - .is_some_and(|(i, _)| i == counter_id) + // Single unguarded catch-all, deliberately. A guarded `_ if flag =>` + // arm here makes any LATER arm unreachable while the flag is true, + // and the compiler cannot warn — reachability depends on the runtime + // guard. #9303's first cut added an index form below exactly such an + // arm and verified as a complete no-op in the range tier while + // passing every flag-false test. New index forms extend the body of + // THIS arm. + _ => { + offset_reads_inlined + && crate::expr::packed_f64_loop_index_parts(index) + .is_some_and(|(i, _)| i == counter_id) } - _ => false, } } Expr::LocalGet(id) => {