fix arity reporting for chaperoned procedures and some primitives
such as `for-each'
This commit is contained in:
parent
3dda2492c2
commit
2dcd76f609
|
@ -70,6 +70,20 @@
|
|||
(for-each (lambda (p)
|
||||
(let ([a (cadr p)])
|
||||
(test a procedure-arity (car p))
|
||||
(when (number? a)
|
||||
(let ([rx (regexp (format "expects(| at least) ~a argument"
|
||||
(if (zero? a) "(0|no)" a)))]
|
||||
[bad-args (cons 'extra (for/list ([i (in-range a)]) 'a))])
|
||||
(test #t regexp-match? rx
|
||||
(with-handlers ([exn:fail? (lambda (exn)
|
||||
(exn-message exn))])
|
||||
(apply (car p) bad-args)))
|
||||
(unless (= a 1)
|
||||
(test #t regexp-match? rx
|
||||
(with-handlers ([exn:fail? (lambda (exn)
|
||||
(exn-message exn))])
|
||||
(for-each (car p) (list bad-args))
|
||||
"done!")))))
|
||||
(test-values (list (caddr p) (cadddr p))
|
||||
(lambda ()
|
||||
(procedure-keywords (car p))))
|
||||
|
|
|
@ -1229,6 +1229,10 @@ char *scheme_make_arity_expect_string(Scheme_Object *proc,
|
|||
int namelen = -1;
|
||||
int mina, maxa;
|
||||
|
||||
if (SCHEME_CHAPERONEP(proc)) {
|
||||
proc = SCHEME_CHAPERONE_VAL(proc);
|
||||
}
|
||||
|
||||
if (SCHEME_PRIMP(proc)) {
|
||||
name = ((Scheme_Primitive_Proc *)proc)->name;
|
||||
mina = ((Scheme_Primitive_Proc *)proc)->mina;
|
||||
|
|
Loading…
Reference in New Issue
Block a user