loon run: abort on checker errors; fix the checker gaps that blocked it#83
Merged
Conversation
The type checker already ran inside `loon run` but its diagnostics were silently discarded, so broken programs printed () instead of teaching diagnostics (agent-first P1: silent-wrong is the worst failure mode). `loon run`, `--wasm`, and `--native` now precheck like `loon check`: errors render to stderr and exit 1; warnings print but don't block. Landing that required teaching the checker the language it was rejecting — 14/35 conformance programs and 6/19 samples failed the checker while running correctly: - when/loop/recur/test special forms (recur targets tracked through loops, named fns, lambdas, and multi-arity clauses) - multi-arity fn: per-clause schemes with arity dispatch at call sites (clauses were unified into one type; infer_fn_clause returned only the body type, so a multi-arity fn's name got a non-function type) - order-flexible collection builtins (map/filter/each/fold/reduce/join detect the collection by type at runtime; the checker now mirrors it) - Record ~ Map unification (record literals are keyword-keyed maps at runtime) and polymorphic map keys for get/assoc/update/merge/remove - compiler-generated ifs (and/or desugar) are unions: don't unify branches, which wrongly constrained pipe lambda params - variadic println/print, generic index-of (vectors too), lenient get on records (absent key is falsy (), per prior-alignment corpus) - sig dimension types pre-apply to fn params so dimensional arithmetic checks inside function bodies; dim names resolve in sigs; Dim is Copy in the ownership check; persistent-collection builtins are borrows, not moves; codegen skips sig Where the checker was right, the programs are fixed instead: - samples/physics.oo computed bending stress as M/span² (N/m, not comparable to Pa) — now M/span³ with a sig annotation - samples/bench-collections.oo reused v1 after moving it - conformance/effects-handlers.oo performed a 1-arg effect op with 0 args cargo test --workspace: all 25 suites green. 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.
|
What shippedRunning a program that contained errors no longer silently prints a blank result. Before this change, broken programs would run anyway and output nothing useful; now, when errors are detected, the tool stops immediately and shows the same clear diagnostics you would see from an explicit check command. Warnings are still shown but do not block execution. Plain-English summary generated by Choji from this pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
loon run(and--wasm/--native) now runs the checker before execution and hard-aborts on errors, rendering diagnostics exactly likeloon check(codespan, to stderr, exit 1). Warnings (W-codes, E0209) print but don't block. Previously the checker ran inside the run path but its diagnostics were discarded (let _errors = checker.check_program(...)), so broken programs silently printed().Why
Priority #1 from the agent-first audit: docs/agent-first.md declares silent wrong behavior the worst failure mode. This converts a whole class of silent
()results into teaching diagnostics — e.g. a typo'd builtin now exits non-zero withE0201 unbound symbolinstead of printing().The catch — and the bulk of the diff
Hard-abort wasn't landable as-is: 14/35 conformance programs and 6/19 samples failed the checker while running correctly. The checker had to learn the language it was rejecting:
when/loop/recur/testforms — previously unbound symbols; recur targets tracked through loops, named fns, lambdas, and clausesfn— clauses were unified into one type (andinfer_fn_clausereturned only the body type, so the fn's name got a non-function type); now per-clause schemes with arity dispatch at call sites, mirroring the VMmap/filter/each/fold/reduce/join, accepting both[map coll fn]and pipe-style[map fn coll]; the checker now mirrors thatmerge/assoc/updateaccept them; map keys generalized from hardcodedKeywordto polymorphick(string-keyed maps type-check)[if g g x]; unifying branches wrongly constrained pipe lambda paramsprintln/print, genericindex-of, lenientgeton records (absent key yields falsy(), per the prior-alignment corpus; dot-access stays strict)sigparam types pre-apply to fn bodies so dimensional arithmetic checks inside functions; dim names resolve in sigs;Dimis Copy in the ownership check; persistent-collection builtins count as borrows; codegen skipssigWhere the checker was right, the programs are fixed instead
samples/physics.oohad a real physics bug: bending stress computed as M/span² (N/m — not comparable to Pa). Now M/span³ with asigannotation. The dimension checker was correctly rejecting it.samples/bench-collections.ooreusedv1after moving it — reordered.conformance/effects-handlers.ooperformed a 1-arg effect op with 0 args — now[E.op 0], same output.Verification
cargo test --workspace: all 25 suites green (conformance, differential, prior-alignment, record/replay included)[println [reduc ...]]exits 1 with the E0201 diagnostic on stderrKnown pre-existing (not a regression, verified against the pre-change binary):
web/src/*.loonfail standaloneloon checkon cross-moduleuseresolution.🤖 Generated with Claude Code