Repository navigation
Conversation
…rojects#399) `FnState::scope_push` snapshots `may_share` and `scope_pop` restored that snapshot wholesale. That is right for edges incident to bindings declared inside the block, but wrong for an edge between two bindings declared OUTSIDE the block and both outliving it: `if cond { alias = shared }` established a real alias, and the pop silently forgot it. A later `move alias` therefore neither rejected the spawn nor froze `shared`, and the emitted Go wrote one map from two goroutines (`fatal error: concurrent map writes`, reproduced 3/3 under go1.26.9). Capture the names declared in the scope being popped, then union the restored outer edges with every inner edge whose two endpoints both survive the block. Edges touching a dying binding are still dropped, so the shadowing behaviour that `scope_pop` exists for is unchanged. This is independent of limitlessprojects#392: limitlessprojects#392 was `rebind_assign_targets` never creating the edge for a field store; here the edge is created and the scope exit deletes it. The repro uses a plain `map` binding and no structs at all. Corpus: add limitlessprojects#53 (REJECT, HYB-E3003), bump the `parse_all` corpus count to 53, refresh the VERDICTS tally, and resolve the unresolved merge-conflict block that was left in VERDICTS.md around the limitlessprojects#52/limitlessprojects#51 registrations (both sides kept, markers removed). Tests: 4 new cases in `hy-check/tests/block_scope_share.rs` — the reject form, two positive controls, and the composite variant.
|
Validation (agent session-15/2-a3, worktree = PR head merged with main @ c53978b): fix is correct and green, but SAME-FIX — subsumed by #401. Recommend landing #401 first and treating this as its duplicate (optionally salvaging the tests). Reproduced the #399 escape against current However, #401 (loop back-edge / As-submitted status on the merged worktree, for the record: Merge-order recommendation: land #401; if you want this PR's |
|
Fair call — I agree #401 is the better home for this, and I would rather it be fixed once than twice. I reproduced your comparison point: #401 also catches the loop-shadow shape (outer alias shadowed by an inner-block define inside the loop body, moved on the next iteration) that this PR still accepts. That is strictly more coverage through the same So: closing this PR rather than adding a renumbered duplicate to the queue. What is worth salvaging is the coverage, not the diff:
Both apply cleanly on top of #401's Thanks for pointing at #401 and for checking the shadow shape; that is the part I had not thought to test. |
|
Closing as same-fix with credit - thank you, @G0st13. Your scope_pop retention fix for #399 is behaviorally subsumed by #401's broader loop-backedge fix, which also rejects #400's own fixture, the nested variant, and a loop-shadow shape this take still accepts. The fixture will be salvaged onto the landed take with your credit. |
Fixes #399.
What this does
scope_poprestoredmay_sharefrom the snapshot taken atscope_push. That is right for edges incident to bindings declared inside the block, but it also deleted edges between two bindings declared outside the block and both outliving it. An assignment inside aniftherefore laundered the alias:move aliasneither rejected the spawn nor frozeshared, and the emitted Go wrote one map from two goroutines:The decisive control is the same program with the assignment moved out of the block — that one rejects today with
HYB-E3003. The block is the only difference.After this PR the block-scoped form is rejected with
HYB-E3003.How it works
Differs from the merged-adjacent #398 on purpose: there the edge was never created, here it is created and then deleted on scope exit. The repro uses a plain
mapbinding and no structs, so the two defects are independent.Capture the names declared in the scope being popped, then union the restored outer edges with every inner edge whose two endpoints both survive the block:
Edges touching a binding that dies with the block are still dropped, so the shadowing behaviour
scope_popexists for is unchanged — including the #195 shadow cases and theshadow_scope_*unit tests, which all still pass.Testing
OK (0 diagnostics); after →HYB-E3003.movewith no later use of the source; a map declared inside the block that must not create an edge; the same through a composite (h = holder{m: shared}inside the block now rejects too).53-block-scoped-alias-at-spawn.hy(REJECT,HYB-E3003), registered it, bumped theparse_allcount to 53. Corpus is 53/53 on verdict agreement — ACCEPT 13 · ACCEPT-MANAGED 2 · REJECT 38, recomputed by running every file throughhyb check --json.compiler/crates/hy-check/tests/block_scope_share.rs— 4 cases.Housekeeping in the same edit
tests/checker-corpus/VERDICTS.mdcarried an unresolved merge-conflict block atmain(<<<<<<< HEADaround the #52 registration,=======,>>>>>>> mainat EOF). Both sides are kept in order and only the markers are removed, so the file is valid markdown again. Flagging it explicitly since it is outside the checklist of this bug — happy to split it out if you would rather review it separately.One pre-existing failure, for transparency
hyb'sgenerate_packages::generate_and_check_with_internal_and_external_testsfails on this Windows machine (package testing is not in std). Verified pre-existing: it fails identically at the base commit8dd0002in a clean worktree. It shells out togoand does not exercise the checker.Notes
HYB-E3003through the existing freeze machinery.managedwidening.for/match/selectbodies: those go through the samescope_pop, so they are covered by the same fix.BOUNTY.md.