From 07f567fcb3750fe3902679d160c080b2fd551a2e Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 27 Jun 2010 08:59:58 -0600 Subject: [PATCH] fix arity handlign and reporting for chaperoned procedures --- src/racket/src/fun.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/racket/src/fun.c b/src/racket/src/fun.c index 45a76a5e4d..f84fdc2f1e 100644 --- a/src/racket/src/fun.c +++ b/src/racket/src/fun.c @@ -4142,6 +4142,18 @@ Scheme_Object *scheme_apply_chaperone(Scheme_Object *o, int argc, Scheme_Object } } + /* Ensure that the original procedure accepts `argc' arguments: */ + a[0] = px->prev; + if (!scheme_check_proc_arity(NULL, argc, 0, 0, a)) { + /* Apply the original procedure, in case the chaperone would accept + `argc' arguments (in addition to the original procedure's arity) + in case the methodness of the original procedure is different + from the chaperone, or in case the procedures have different names. */ + (void)_scheme_apply_multi(px->prev, argc, argv); + scheme_signal_error("internal error: unexpected success applying chaperoned procedure"); + return NULL; + } + v = _scheme_apply_multi(px->redirects, argc, argv); if (v == SCHEME_MULTIPLE_VALUES) { GC_CAN_IGNORE Scheme_Thread *p = scheme_current_thread;