Implement [use ...] module imports on the EIR backend#77
Conversation
The EIR lowering inlined imported modules but three gaps broke real multi-file programs on the default backend: - Non-pub fns were never qualified: mirror the interpreter's export rule (all top-level fns when a module declares no pub). - Alias syntax checked for a symbol `as`; the real syntax is the keyword `:as`. Default prefix now uses the full dotted module path. - Checker E05xx module diagnostics (unresolved module, circular dependency) were discarded; all four EIR entry points now fail fast with a new VmErrorKind::ModuleError instead of a confusing NotCallable at the first qualified call site. Adds integration tests: non-pub use, :as alias, nested modules, missing module error, circular import error. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Choji review — Looks good This PR fixes three real gaps in the EIR backend's Correctness
1 minor finding
Choji ran your change live — checks failed. The ticket asked for working Because the environment couldn't run
Checks — failures
No issues found in the running app. Was this review useful? Rate the findings → — your thumbs up or down trains Choji on what's worth flagging. Reviewed |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
What shippedThis is an internal change with no user-visible effect on most users, but it does fix a real breakage for anyone using multi-file Loon programs. Multi-file programs using Plain-English summary generated by Choji from this pull request. |
What
Makes multi-file programs work on the default
loon run(EIR VM) backend. Previously[use lib]was effectively a stub:lib.oowith[fn triple [x] [* x 3]]+[use lib] [println [lib.triple 5]]printed 15 under--legacybut died with "value is not callable" on the EIR VM.Why
Unblocks the package manager (pkg.oo/lock.oo, grants, audit — implemented but moot without working imports on the default backend) and the loon-os multi-module work.
Changes
The lowering pass already inlined imported modules (
collect_importsineir/lower.rs); three gaps broke it in practice:pub fns got qualifiedalias.nameentries. The legacy interpreter (module.rs) exports all top-level fns when a module has nopub; the EIR path now matches.as, but the syntax is the keyword:as([use math :as m]), sosamples/modules/main-alias.oofailed. Default qualification now uses the full dotted module path, exactly like the interpreter.VmErrorKind::ModuleError;eval_eir{,_with_base_dir,_recorded,_replayed,_verified}now fail fast on E05xx with the diagnostic message and span.Verification
samples/modules/main.ooandmain-alias.ooproduce identical output on EIR and--legacyeir/vm.rs: non-pub use,:asalias, nested module-calling-module, missing module error, circular import errorcargo test --workspacepasses;cargo fmtcleanKnown limitation (pre-existing)
Only functions get qualified names — a top-level
letin a module imports bare but not aslib.name, since qualification goes through the func map. Worth a follow-up if the package manager needs module constants.🤖 Generated with Claude Code