You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 974f08a
Browse filesBrowse the repository at this point in the historyBrowse files
fix: guard int tracking, swallowed returns, import name hygiene (#797 review)
Four findings from the CodeRabbit review of #797, each verified and
pinned by a test that fails without its fix.
Bun-ESM backend:
- A match arm's guard is emitted before its body, and a tail-position
block runs in its own scope of integer tracking (`with_int_scope`), so
a `let n = 0.5` in an arm's body no longer turns the guard's `n / 2`
into float division.
- `gen_tail_to` refuses a `return` in a form it emits as an expression
(`[{ return 7; 0 }]`), where the IIFE would have swallowed it.
Module flattening:
- A public declaration carried only for its module's own callers (the
original of an aliased import, or a helper only a selected function
calls) gets an internal name, with its references rewritten. With
`use A::{helper as ah, api}` and `use B::{helper as bh}`, both
`helper`s were emitted under `helper` and `api` called B's.
- Internal names length-prefix each module path component, so `A_B.C`
and `A.B_C` no longer give the same name.
- Aliasing a mutable module binding (`const mut`) is refused: the alias
would be a second, separate copy.
- Both errors are a structured `Flatten_error`, reported by `eval` and
`compile` as a diagnostic (E0206 with `--json`), instead of an uncaught
`Failure`.
Tests: five new cases in test/test_module_root_flatten.ml. Reverting
each fix (the int scoping, the fallback refusal, the internal names, the
injective encoding, the mutable-alias refusal) makes its test fail. Full
suite: no failures beyond the 33 walker-* tests that need tree-sitter
(same on main). kyq parser and lint drivers: 0 failures under Bun.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P4yFkxW5Heb8p2YW7ZYs9F
Copy file name to clipboardExpand all lines: docs/COMPLETION-PLAN.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -221,7 +221,7 @@ All were observed by RUN unless marked otherwise. The maps confirm that H1–H4
221
221
. H18. The interpreter fails when dereferencing refs returned through calls ("Expected reference type"). The session lead reproduced this on two #554 fixtures.
222
222
. H19 (typed-wasm). No L5 index guard: `get_player_hp(0,150)` reads an adjacent region. `where` constraints are discarded. Malformed `session` blocks are silently ignored.
223
223
. H23 (found and fixed 2026-11-09, checking and running metadatastician/kyq; numbered H20 in #788, renumbered because #787 assigned H20–H22). A module file found for `A.B` that declares `module A;` was accepted as `A.B`, so `use A.Nonexistent::*` type-checked and imported `A`'s exports; it is now a `ModuleDeclMismatch` load error. *Round 2 (2026-11-16):* a nested candidate (`dir/A/B.affine`) is now searched in every directory before any parent-module fallback, and a module whose load fails is no longer left marked as loading (which reported a later import of it as a cycle). Anchor: `test/test_module_root_flatten.ml`.
224
-
. H24 (found and fixed 2026-11-09; numbered H21 in #788). `eval` ran the unflattened program, so no imported function was bound at run time; flattening also emitted a selected function before the private helpers it calls and carried no helpers for glob or plain imports. `eval` now flattens, every import kind carries its helpers, and they are emitted in the imported module's declaration order. *Round 2 (2026-11-16):* two modules with a same-named private helper no longer collide: every private helper carried into a flattened program is renamed `__priv_<Module>__<name>` with a capture-avoiding substitution, and an aliased import emits the original before the alias. Only the root program's `main` is run. Anchor: `test/test_module_root_flatten.ml`.
224
+
. H24 (found and fixed 2026-11-09; numbered H21 in #788). `eval` ran the unflattened program, so no imported function was bound at run time; flattening also emitted a selected function before the private helpers it calls and carried no helpers for glob or plain imports. `eval` now flattens, every import kind carries its helpers, and they are emitted in the imported module's declaration order. *Round 2 (2026-11-16):* two modules with a same-named private helper no longer collide: every private helper carried into a flattened program is renamed `__priv_<Module>__<name>` with a capture-avoiding substitution (the module path is length-prefixed, so `A_B.C` and `A.B_C` cannot share a name), and an aliased import emits the original before the alias. *Round 3 (2026-11-16):* a public declaration carried only for the module's own callers (the original of an alias, or a helper only a selected function calls) gets an internal name too, so two modules' `helper`s cannot replace one another; aliasing a mutable binding, which would make a second copy, and an unresolvable name collision are structured flattening errors (diagnostic E0206), not exceptions. Only the root program's `main` is run. Anchor: `test/test_module_root_flatten.ml`.
225
225
. H25 (found and fixed 2026-11-09; numbered H22 in #788). The interpreter had no `++` on arrays and no `==`/`!=` beyond Int, Float, String and Bool, though the checker accepts them; it now uses the structural `Value.value_eq`. H7 (`let mut`) is unchanged. Anchor: `test/test_module_root_flatten.ml`.
0 commit comments