Index: TODO =================================================================== diff -u -ra66203fd33ab456ca54176524897ada53c89d13b -r2cd96f38dddd3c2c2a3ab71abf68ac7f5ad7d879 --- TODO (.../TODO) (revision a66203fd33ab456ca54176524897ada53c89d13b) +++ TODO (.../TODO) (revision 2cd96f38dddd3c2c2a3ab71abf68ac7f5ad7d879) @@ -2027,6 +2027,8 @@ - deprecate allowempty in parameter specs in favor of multiplicity - adjust regression test +- fixed bug with required last object parameter without provided value +- extended regression test TODO: Index: generic/nsf.c =================================================================== diff -u -r350395592496276bc98362b9dadb03f663e25f0b -r2cd96f38dddd3c2c2a3ab71abf68ac7f5ad7d879 --- generic/nsf.c (.../nsf.c) (revision 350395592496276bc98362b9dadb03f663e25f0b) +++ generic/nsf.c (.../nsf.c) (revision 2cd96f38dddd3c2c2a3ab71abf68ac7f5ad7d879) @@ -11988,11 +11988,11 @@ o++; p++; if (nppPtr->flags & NSF_ARG_REQUIRED) nrReq++; else nrOpt++; - if (o < objc) { + if (p < objc) { #if defined(PARSE_TRACE_FULL) fprintf(stderr, "... setting cd[%d] '%s' = %s (%d) %s converter %p\n", i, nppPtr->name, ObjStr(objv[p]), nppPtr->nrArgs, - nppPtr->flags & NSF_ARG_REQUIRED ? "req":"not req", nppPtr->converter); + nppPtr->flags & NSF_ARG_REQUIRED ? "req" : "not req", nppPtr->converter); #endif if (ArgumentCheck(interp, objv[p], nppPtr, doCheck, &pcPtr->flags[j], &pcPtr->clientData[j], &pcPtr->objv[j]) != TCL_OK) { @@ -15336,8 +15336,8 @@ } newValue = pc.full_objv[i]; - /*fprintf(stderr, "new Value of %s = %p '%s', type %s\n", - ObjStr(paramPtr->nameObj), + /*fprintf(stderr, "new Value of %s = [%d] %p '%s', type %s\n", + ObjStr(paramPtr->nameObj), i, newValue, newValue ? ObjStr(newValue) : "(null)", paramPtr->type); */ if (newValue == NsfGlobalObjs[NSF___UNKNOWN__]) { Index: generic/nsf.h =================================================================== diff -u -r00c0ab7734c498b435b2005173928687e48d7f23 -r2cd96f38dddd3c2c2a3ab71abf68ac7f5ad7d879 --- generic/nsf.h (.../nsf.h) (revision 00c0ab7734c498b435b2005173928687e48d7f23) +++ generic/nsf.h (.../nsf.h) (revision 2cd96f38dddd3c2c2a3ab71abf68ac7f5ad7d879) @@ -90,7 +90,6 @@ /* turn tracing output on/off #define NSFOBJ_TRACE 1 - #define CALLSTACK_TRACE 1 #define NAMESPACE_TRACE 1 #define OBJDELETION_TRACE 1 Index: library/xotcl/tests/slottest.xotcl =================================================================== diff -u -rcc94b154709f9bd3393fbbdb9af982a30b57dee0 -r2cd96f38dddd3c2c2a3ab71abf68ac7f5ad7d879 --- library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision cc94b154709f9bd3393fbbdb9af982a30b57dee0) +++ library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision 2cd96f38dddd3c2c2a3ab71abf68ac7f5ad7d879) @@ -349,10 +349,23 @@ a1 foo 123 ;# calls overridden foosetter ? {a1 foo} 123 - #puts [A serialize] ################### +Test case req-param { + ::xotcl::Class create C -parameter {y:required x:required} + C instproc init args {set ::_ $args} + + set ::_ "" + ? {C create c2 -y 1 -x} {Argument for parameter '-x' expected} + ? {set ::_} "" + ? {c2 x} {can't read "x": no such variable} + ? {C create c3 -y 1 -x 0} "::c3" + ? {set ::_} "" + ? {c3 x} "0" +} + +################### # Application Slots # Index: tests/parameters.test =================================================================== diff -u -r350395592496276bc98362b9dadb03f663e25f0b -r2cd96f38dddd3c2c2a3ab71abf68ac7f5ad7d879 --- tests/parameters.test (.../parameters.test) (revision 350395592496276bc98362b9dadb03f663e25f0b) +++ tests/parameters.test (.../parameters.test) (revision 2cd96f38dddd3c2c2a3ab71abf68ac7f5ad7d879) @@ -1386,3 +1386,19 @@ ? [list [current] info vars :a1] "" } } + +Test case req-param { + ::nx::Class create C { + :attribute y:required + :attribute x:required + :method init args {set ::_ $args} + } + + set ::_ "" + ? {C create c2 -y 1 -x} {Argument for parameter '-x' expected} + ? {set ::_} "" + ? {c2 x} {can't read "x": no such variable} + ? {C create c3 -y 1 -x 0} "::c3" + ? {set ::_} "" + ? {c3 x} "0" +}