say which macro call an error came from

A wrong argument count was CHICKEN's to report, about a procedure with
no name, and an error raised in a macro's body said nothing of the call.
This commit is contained in:
2026-10-19 10:23:59 +03:00
parent 3560a8c226
commit 25cdb613a4
2 changed files with 47 additions and 4 deletions

View File

@@ -385,7 +385,22 @@ whitespace aside, THEN?"
(test-assert "the offending form is shown too"
(reports? "(include stdio.h)\n(wat 1 2)" "(wat 1 2)"))
(test-assert "pub with nothing to define"
(reports? "(pub 1)" "codegen.sex:1:")))
(reports? "(pub 1)" "codegen.sex:1:"))
;; a macro's arity was CHICKEN's to report, about a procedure with
;; no name; and an error in its body said nothing of the call
(test-assert "a macro given the wrong number of arguments"
(reports? "(defmacro (one x) x)\n(fn f () int\n (return (one 1 2)))"
"codegen.sex:3: macro takes this many arguments one 1"))
(test-assert "at toplevel too"
(reports? "(defmacro (one x) x)\n(one)" "codegen.sex:2: macro takes this many arguments"))
(test-assert "and one taking the rest, too few"
(reports? "(defmacro (many x . more) x)\n(fn f () int (return (many)))"
"macro takes at least this many arguments many 1"))
(test-assert "while it may take any more"
(emits? "(defmacro (many x . more) x) (fn f () int (return (many 1 2 3)))" "return 1;"))
(test-assert "an error in a macro's body names the call"
(reports? "(defmacro (boom x) (error \"no good\" x))\n(fn f () int (return (boom 1)))"
"codegen.sex:2: expanding boom: no good")))
;; A grouped header, C's parens carried over, died in the writer with
;; `(caddr) bad argument type' and no location