From 0d3c1d543dacc770e745710b52d9ea1c4d1a28f2 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 15 Aug 2010 16:16:07 +0000 Subject: * generic/tclProc.c (ProcWrongNumArgs): [Bug 3045010]: Make the handling of passing the wrong number of arguments to [apply] somewhat less verbose when a lambda term is present. --- ChangeLog | 6 ++++++ generic/tclProc.c | 12 +++++++----- tests/apply.test | 6 +++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0508bf9..642279a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-08-15 Donal K. Fellows + + * generic/tclProc.c (ProcWrongNumArgs): [Bug 3045010]: Make the + handling of passing the wrong number of arguments to [apply] somewhat + less verbose when a lambda term is present. + 2010-08-12 Donal K. Fellows * generic/tclCmdMZ.c (Tcl_RegexpObjCmd): [Bug 2826551, Patch 2948425]: diff --git a/generic/tclProc.c b/generic/tclProc.c index 3c8f810..0723a1e 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclProc.c,v 1.139.2.6 2009/08/25 21:01:05 andreas_kupries Exp $ + * RCS: @(#) $Id: tclProc.c,v 1.139.2.7 2010/08/15 16:16:07 dkf Exp $ */ #include "tclInt.h" @@ -1092,13 +1092,15 @@ ProcWrongNumArgs( desiredObjs = (Tcl_Obj **) TclStackAlloc(interp, (int) sizeof(Tcl_Obj *) * (numArgs+1)); + if (framePtr->isProcCallFrame & FRAME_IS_LAMBDA) { + desiredObjs[0] = Tcl_NewStringObj("lambdaExpr", -1); + } else { #ifdef AVOID_HACKS_FOR_ITCL - desiredObjs[0] = framePtr->objv[skip-1]; + desiredObjs[0] = framePtr->objv[skip-1]; #else - desiredObjs[0] = ((framePtr->isProcCallFrame & FRAME_IS_LAMBDA) - ? framePtr->objv[skip-1] - : Tcl_NewListObj(skip, framePtr->objv)); + desiredObjs[0] = Tcl_NewListObj(skip, framePtr->objv); #endif /* AVOID_HACKS_FOR_ITCL */ + } Tcl_IncrRefCount(desiredObjs[0]); defPtr = (Var *) (&framePtr->localCachePtr->varName0 + localCt); diff --git a/tests/apply.test b/tests/apply.test index 4e8eeea..5235de3 100644 --- a/tests/apply.test +++ b/tests/apply.test @@ -12,7 +12,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: apply.test,v 1.12.2.1 2009/10/29 17:21:17 dgp Exp $ +# RCS: @(#) $Id: apply.test,v 1.12.2.2 2010/08/15 16:16:07 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2.2 @@ -104,12 +104,12 @@ test apply-4.1 {error in arguments to lambda expression} { set lambda [list x {set x 1}] set res [catch {apply $lambda} msg] list $res $msg -} {1 {wrong # args: should be "apply {x {set x 1}} x"}} +} {1 {wrong # args: should be "apply lambdaExpr x"}} test apply-4.2 {error in arguments to lambda expression} { set lambda [list x {set x 1}] set res [catch {apply $lambda a b} msg] list $res $msg -} {1 {wrong # args: should be "apply {x {set x 1}} x"}} +} {1 {wrong # args: should be "apply lambdaExpr x"}} test apply-4.3 {error in arguments to lambda expression} { set lambda [list x {set x 1}] interp alias {} foo {} ::apply $lambda -- cgit v0.12