From fd45b3478e152b120202becd1aa70dc6ebf84b71 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 8 Jun 2011 17:15:40 +0000 Subject: [PATCH] Kludge up wrong-number-of-arguments error parsing for entities. Before: (min) ;The procedure #[compiled-procedure 11 (min "arith" #x16) #x1b1a #x1c8ac2] has been called with 1 argument; it requires at least 2 arguments. After: (min) ;The procedure #[arity-dispatched-procedure 11 min] has been called with 0 arguments; it requires at least 1 argument. Screw cases be damned. --- src/runtime/uerror.scm | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/runtime/uerror.scm b/src/runtime/uerror.scm index 874f92f69..7387ad177 100644 --- a/src/runtime/uerror.scm +++ b/src/runtime/uerror.scm @@ -933,11 +933,20 @@ USA. (lambda (continuation) (let ((frame (continuation/first-subproblem continuation))) (if (apply-frame? frame) - (let ((operator (apply-frame/operator frame))) - (signal continuation - operator - (procedure-arity operator) - (apply-frame/operands frame)))))))) + ;; This is a heuristic kludge. It can break down: + ;; (let ((p (lambda (x y) 0))) + ;; (p (make-entity p 0))) + ;; But without the kludge, (min) gives a confusing error, + ;; which is probably more common than this pathological + ;; case. + (let loop ((operator (apply-frame/operator frame)) + (operands (apply-frame/operands frame))) + (if (and (pair? operands) + (entity? (car operands)) + (eq? operator (entity-procedure (car operands)))) + (loop (car operands) (cdr operands)) + (let ((arity (procedure-arity operator))) + (signal continuation operator arity operands))))))))) (define-error-handler 'FLOATING-OVERFLOW (let ((signal -- 2.25.1