Skip to content

Non-inferrable errors drop the term echo; locations underline their span - #1063

Merged
nicolas-abril merged 5 commits into
mainfrom
err-caret
Sep 25, 2026
Merged

nicolas-abril merged 5 commits into
mainfrom
err-caret

Conversation

@nicolas-abril

@nicolas-abril nicolas-abril commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Five commits:

1. A non-inferrable term's observed reads "non-inferrable term" (38cb7db)

typeless_show goes. The four check sites with no type for the observed slot (a lambda, a match, {==}, an undeclared constructor against a goal of the wrong shape) pass the fixed text non-inferrable term instead of echoing the term. The "X is a datatype: write its arguments as <>" hint on a Ctr naming a datatype moves to the error's Note:. Four golds change.

2. An error's location underlines its span (66ecce0)

The echo was the only thing that pinpointed the subterm, since the location marks a line, not a column. err_show now adds a caret line under the marked line, from the span's first column to its end, clipped to that line (one ^ for an empty span; tabs in the prefix are kept so it lines up):

Location: t
4 |
5>| def t(b: Bool) -> Maybe{&2, Bool}:
  |                   ^^^^^^^^^^^^^^^
6 |   match b:

Every gold with a location gains its caret line and nothing else (verified by script: removing the caret lines gives back the old gold). parse/do_bind_continuation, whose error points past its own last line, renumbers to its new length.

3. A constructor that misses its goal throws once (437c420)

The Ctr site's two throws become one, and err_show's line-number width is num, so it no longer shadows the context's wid.

4. A parse error on a token it has read underlines that token (74bd10d)

parse_fail marked a zero-width span at the parser's position, which for an error raised after reading a token is the column past it (law law⟦ ⟧: Type, law main⟦:⟧, case Zw{}, x, Zw{}:⟦⟧). It now takes the token's start (and, for a case's patterns, its end), and shows the token as observed:

6>| law law : Type
  |     ^^^

This covers a keyword used as a name, a duplicate declaration or field, a bad dotted name, a u32 literal past 4294967295, a keyword heading a term, and a case with the wrong number of patterns. 42 golds change only in their observed and caret lines.

5. err_show takes the caret's column from the prefix it already splits (1bd0d9b)

The text left of the span on its line is the last piece of the split that counts the line, so parse_col and three locals go. Output is byte-identical.

In total, bend2/bend.ts grows by 123 ttok (43761 → 43884, cap 44000).

Notes for review:

  • A lambda's span is its binder (Lam(x.k, x.i, f, x.s, x.q) in the parser), so x => add_zero(x) underlines only x. Left as is since binder errors rely on it.
  • A multi-line span underlines only its first line.
  • This touches ~475 golds, so open PRs that add error tests will need their golds regenerated.
  • bend2/bend.ts is edited, which AGENTS.md reserves for humans; flagging it.

Testing: the 481 error-expecting tests run locally through bend2/main.ts pass 478/481 after all four commits, same as main; the other 982 tests still pass --check-only (the 3 misses are IO tests whose errors come from the compile lane, which the local runner doesn't run). tsc shows the same 4 pre-existing errors as main. The cluster gate hasn't been run.

🤖 Generated with Claude Code

nicolas-abril and others added 5 commits September 25, 2026 14:59
…ation already points at it

typeless_show goes. The four check sites that have no type for the observed
slot (a lambda, a match, {==}, an undeclared constructor against a goal of the
wrong shape) now pass the fixed text, and the datatype hint on a Ctr that
names a datatype moves to the error's Note.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…d line

err_show puts ^ from the span's first column to its end, clipped to that line
(one ^ for an empty span; tabs in the prefix kept so it lines up). Every gold
with a location gains its caret line and nothing else; do_bind_continuation,
whose error points past its own last line, renumbers to its new length.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… width is num: the context's wid is no longer shadowed

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…olumn past it

parse_fail takes the token's start (and, for a case's patterns, its end):
a keyword used as a name, a duplicate declaration or field, a bad dotted
name, a u32 literal past 4294967295, a keyword heading a term and a case
with the wrong number of patterns now underline the token and show it as
observed. parse_def resolves its name before the ? mark, so the name ends
where parse_fresh looks. 42 golds change only in their observed and caret
lines.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…or the line

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@nicolas-abril
nicolas-abril merged commit db84f20 into main Sep 25, 2026
VictorTaelin added a commit that referenced this pull request Sep 26, 2026
… descent is linear

bend2/bend.ts (43,884 -> 42,275 ttok):
- The parser reads every infix operator from one INFIX table (longest
  spelling wins), not a list, three special branches and an if-chain.
- The parser's binder stack and frame count live on Parse: Scope, Entry
  and Loc go; parse_book resets them once per declaration.
- A reply is its term: the Reply type goes (Body = Match | Local | LTerm).
- parse_term sets the span of a node that lacks one, so the branches that
  set the same span go, and parse_grow goes.
- {a == b : T}, {a != b : T} and {a : T} share one tail; parse_book and
  parse_def read a word once; parse_lookup, parse_term_do_call go.
- term_higher, term_lower and term_snf return a leaf as it is; the dead Sub
  cases of term_lower and term_snf go; Sub.v is a Patt.
- term_wnf's MAT frame applies its lambda-match in one place.
- term_compare: one case for Qnt, Efq and Rfl.
- uses_close closes a binder (quant_used, uses_get, uses_del go);
  ctrs_find goes; book_fam reads tele_unbind; def_inst checks its ~
  arguments with tele_check; book_valid checks a def in place.
- The book adds an open law to hols: the open field goes.
- err_show prints a context type with expr_show; char_is_name extends
  char_is_head.
- #983: term_descend skips the field that already missed, so a descent
  on a Nat literal is linear, not 2^n (tests/halt/literal_descent_linear).
- Header comments that were false now match the code.

bend2/comp.ts (63,523 -> 62,584 ttok), effs/chan.c, effs/tcp_poll.c,
effs/file_read.c, effs/window_frame.c:
- One type walk, ty_holds, finds closures and recursive datatypes:
  lay_cyclic and its cache go.
- An IO fiber is its IoWork: the IoAct wrapper and io_wait_time go.
- The pool counts with the a32 atomics: its _Atomic globals go.
- A Halt or a deadlock ends the program where the IO loop meets it; the
  CLI fails through err_fail (cli_fail goes); same texts, same codes.
- A term's spine holds its call: the Call type and call_kind go.
- One effect_srcs reads each foreign source once for both lanes.
- One mat_rows gives both lanes a match's rows; Seg.host goes.
- term_keep takes its count; the kernel votes in its group's block;
  GA32, ALC_WORDS and fid_seqk go.
- The compiler's types go from 31 to 16. One File record holds a
  compile, and a nested scope is a copy of it (Carb, Src, Dst and Show
  go); a def's raised arity and body live in its Fun, and the book is
  never copied (Def, TLD and Sig go); a flat layout's arms map a
  constructor to its fields' layouts (Arm and Field go); Nat and word
  match rows are one Row (Chain and Leaf go); HAdt, HLet, UMap and Probe
  are written as Of<K>.
- The C runtime's type names go from 26 to 14: it speaks u64, u32 and
  pointers (Loc, Cls, Fid, Err, Ring, Nat, U32, Stk, Corpus go), one
  atomic family serves host, Metal and CUDA (g32 and Cur go), the five
  u8 id tables are two byte-row tables FID_T and CID_T, and an IO queue
  is a circular list held by its last IoWork (IoQue goes).
- The JS lane runs 2.3x faster than #1061's (benches: bun 2.7x, node
  2.9x; other programs: bun 2.5x, node 1.5x) and recurses at least as
  deep: a Nat is a JS number, exact below the 2^48 cap C shares. #1061's
  tail-cycle loops stay the one call design (loop_of; a one-def cycle
  needs no $pc), and a call passes through run_loop only when its callee
  may return a closure's bounce: a marker per call resolves once every
  def is out, so a def that never bounces is called directly (bun: fib
  0.40 s against 0.65 s with run_loop on every call; node: gameoflife
  0.26 s against 0.76 s). A Nat from the host enters through nat_host: an
  integer up to 2^53 is exact, any other value fails like C's Nat check
  (tests/io/nat_host_bounds, nat_host_neg, nat_host_chan); an array
  converts in place, as before; a match field an arm never reads is not
  bound.
- Dead internal guards go; term_any walks a tree without a visited set.
- On main since b531388: #1068's wide nodes (WIDE 247, a node past it
  keeps 240 plus its size class in CID_T), #1038's intrinsic argument
  layouts, #988's --bend-help and #1061's Nat.min/max rows, in this
  model; {a != b : T} underlines its != as #1063 does.

WONTFIX.txt, guide/GUIDE.md: stale lines match the CLI and the runtime.

The emitted C differs only in the runtime text above (a program's
segments are the same, but a foreign request's local names). The emitted
JS behaves as main's for every test, demo and generated program, except a
bad Nat from the host (negative, past 2^53, not an integer), which now
fails as the C lane does instead of printing garbage. 8,286 programs and
mutants against 11c65a2: the same check, interpreter, JS (bun and node)
and C output (1,414 binaries), except those host-Nat cases and
literal_descent_linear, which main does not finish. C lane on the M4
minis (16 benches, min of 5): SEQ 0.999, PAR 0.999, GPU 1.000; emit
0.98. Linux x86 (clang-19, RTX 4090): every test, bench and CUDA test
prints as on main.

bend.ts and comp.ts follow STYLE.md: no prose comment sits in the middle
of a section (a fact the code does not show moves, in one short sentence,
into its section's doc block; comp.ts goes from 150 comment blocks to 47);
trailing comments line up; a checker function sits in Check (tele_check,
term_descend, uses_close) and f32_show in Show; each comp.ts section is a
type or a verb and holds its subject's functions (Live is Dom, Anf is ANF,
the type Gen is Tpl, emit_nats and emit_lits are mat_nats and mat_lits);
every case of a switch is a block; the title comes first; TAB_BAD,
RUNTIME_ADTS, OWNED, IDS and TAKEN move into Constants; no comp.ts line
passes 80 chars. The code tokens are unchanged: the emitted C and JS
differ only in runtime comments and whitespace.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@nicolas-abril
nicolas-abril deleted the err-caret branch October 1, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant