fix: unary arithmetic type-error message no longer crashes the reporter
rewrite-message assumed janet's BINARY arithmetic dispatch error shape
("could not find method :+ for 1 or :r+ for "a""). Unary inc/dec/- on a
non-number produce "could not find method :+ for "x"" — no "or :r" clause
— so orpos was nil and the reporter itself threw "could not find method :+
for nil", burying the real error. Handle the unary form. Found auditing
the RFC 0006 checker's default (checker-off) path. Regression row in
cli-test.
This commit is contained in:
parent
f2d65addc8
commit
37949ac602
2 changed files with 19 additions and 7 deletions
|
|
@ -45,6 +45,12 @@
|
|||
(check "arith error message rewritten"
|
||||
(run-err "-e" `(+ 1 "a")`)
|
||||
(has `Cannot add 1 and "a"`))
|
||||
# unary arithmetic (inc/dec) on a non-number: the host error has no "or :r"
|
||||
# clause, which used to crash the rewriter itself — handle it (jolt audit)
|
||||
(check "unary arith error does not crash the rewriter"
|
||||
(run-err "-e" `(inc "x")`)
|
||||
(fn [s] (and (string/find "expects numbers" s)
|
||||
(nil? (string/find "could not find method" s)))))
|
||||
(check "arity error names the fn"
|
||||
(run-err "-e" "(defn afn [x] x) (afn 1 2)")
|
||||
(has "Wrong number of args (2) passed to: user/afn"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue