flan/test/programs/dyn-trap-site.flan
Joseph Ferano 78d9a0f051 The review's fixes: a suggestion that does not compile, and a confident wrong guess
F1 was the blocker and it was the worst kind of fault this pass can have: the
condition message told the reader to write (not= x 0), and not= does not
exist — the operator is !=. Applying the compiler's own advice got 'unknown
function not= — did you mean not?'. Both branches say != now, and all three
— the named form, the float zero, and the unnamed one — were checked by
compiling the sentence the compiler prints.

F5: a typo of a declared capitalised name got the generics lecture. (Piont 1
2) with Point declared was told that a capitalised name given type arguments
is milestone 5 work, which is a confident answer about a feature nobody was
reaching for. The did-you-mean runs first and, for a capitalised head only,
asks the type tables as well; the generics sentence is left for a head that
resembles nothing.

F2: flan_dyn_cast_kind had the site live and passed NULL on the trapping
path — the one entry point on this side that had a location and threw it
away. The acceptance row now pins the prefix it prints.

F3: the case-typo row used (data ...), which is not a top-level form, so it
refused as an unknown top-level form and the needle 'unknown' matched that
rather than the rule. Rewritten with defdata, and as a pair: a capitalised
head gets no accessor advice, a lowercase one does. Both halves were checked
to fail when perturbed.

F4: an end-to-end pin for the headline. programs/dyn-trap-site.flan is
compiled, run, and its stderr read for the file:line:col in front of the
sentence, on both backends and at -O0. Proven live: three failures when the
expected line is wrong.

F8: usize and size_t stay off the foreign-spelling list, and the comment now
says why — the honest answer is pointer-width, which is u64 here and u32 on
wasm32, and a tree that builds both cannot name one of them.

F10 pins the fourth dot shape. F6 moves the not-reached reasons out of the
commit bodies and into FIX.org, where they can be read without git.
2026-09-20 18:46:48 +07:00

29 lines
1.3 KiB
Plaintext

;;;; A dyn arithmetic trap says where it happened.
;;;;
;;;; In a dynamic-first language the dyn traps ARE the type errors, and until
;;;; the diagnostics pass they printed with no file, no line and no column:
;;;;
;;;; dyn +: int and text, and it takes two numbers — (+ 3 "hi")
;;;;
;;;; flan_rt.c's bounds and arithmetic traps have taken an emitter-threaded
;;;; (loc, loclen) pair since they were written, so the ABI precedent was
;;;; already there; the five arithmetic and four ordering entry points in
;;;; flan_dyn.c simply were never given one. They take it now, and the trap
;;;; prints it as the GNU "file:line:col: " prefix, which is what makes
;;;; next-error walk to a dyn failure the way it walks to a bounds failure.
;;;;
;;;; This program exists for the prefix and for nothing else. The line prints
;;;; first so that the test can tell "the program ran and then trapped" from
;;;; "the program did not start", and the operation is inside a defn so that
;;;; the site reported is the operator's own and not the call's — which is the
;;;; distinction that matters: the + is what failed, and the + is what the
;;;; caret should be under.
(defn add [x y] dyn
(+ x y))
(defn main [] ()
(print "before\n")
(print (add 3 "hi"))
(print "unreachable\n"))