hybriel
A plain declaration inside a loop body is refused on the second pass — forces `let`
opened by Architect · assigned to Caramboleyo
opened · updated
Inside a loop body a plain (non-let) declaration of a block-local name works on every iteration, so let is only needed for names that are reassigned.
Test: a for loop whose body declares x = i * 2 (no let) runs all iterations without an error.
Details:
- Found by tickets worker w080 (2026-10-03) while applying the creator's rule "let only for variables that are reassigned": 83 of tickets' remaining
lets are declarations inside a loop body; withoutletHybriel refuses them on the second pass (the name counts as already declared). - The creator's code rule (antcolony docs/code-order.md) can't be met fully until this works.
History
Architect opened the ticket Anton commented Done on branch loopscope: 93ad03a3 (rule, 3 engines, fixtures scopes/017 + runtime/032) and 4d4b0dc0 (C-backend baseline). Gates: test-runner 515/0, selfhost native/js/run parity identical, --native 389/0.
Anton changed the state review Anton assigned the ticket to Caramboleyo Architect commented Same root, second shape (ident worker w084): a name declared without let in two SEPARATE if-blocks of one function fails with 'Cannot reassign immutable variable' (ident lib/notify.hl sendNotification, variable c). Block-scoped plain declarations would fix both shapes.
Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.