From 38e891efc6187e9d4d55fade7cb8287ccecc2803 Mon Sep 17 00:00:00 2001 From: Ralph Date: Tue, 7 Jul 2026 00:53:06 -0700 Subject: [PATCH] fix(hir): queue with-statement bodies as nested forward-capture scopes (review feedback) push_nested_block_stmt_lists handled if/loop/labeled wrappers but not With, so a block-scoped forward-captured let inside a sloppy-mode 'with (o) { ... }' body never pre-registered (mirrors the existing With arm in cic_stmt). Battery of 11 nested-forward-capture parity cases still matches node; with-shape returns the block-lexical binding per spec. Co-Authored-By: Claude Fable 5 --- crates/perry-hir/src/lower_decl/block.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/perry-hir/src/lower_decl/block.rs b/crates/perry-hir/src/lower_decl/block.rs index 97a0e1e44f..c73f06165c 100644 --- a/crates/perry-hir/src/lower_decl/block.rs +++ b/crates/perry-hir/src/lower_decl/block.rs @@ -291,6 +291,10 @@ fn push_nested_block_stmt_lists<'a>( While(w) => push_nested_block_stmt_lists(&w.body, worklist), DoWhile(w) => push_nested_block_stmt_lists(&w.body, worklist), Labeled(l) => push_nested_block_stmt_lists(&l.body, worklist), + // Sloppy-mode `with (o) { … }` — a block-scoped `let` in the body is + // nearer than the with-object's properties, so it forward-captures + // like any other nested block (mirrors the `With` arm in `cic_stmt`). + With(w) => push_nested_block_stmt_lists(&w.body, worklist), Switch(sw) => { for c in &sw.cases { worklist.push_back((&c.cons[..], true));