Index: generic/nsf.c =================================================================== diff -u -rc64f818543a3e40ed1fafcc58c50324448b39266 -r3ed6440e2cbe7612bba89469b3c44c376d857338 --- generic/nsf.c (.../nsf.c) (revision c64f818543a3e40ed1fafcc58c50324448b39266) +++ generic/nsf.c (.../nsf.c) (revision 3ed6440e2cbe7612bba89469b3c44c376d857338) @@ -14207,31 +14207,24 @@ } else { /* no unknown called, this is the built-in unknown handler */ Tcl_Obj *tailMethodObj = NULL; - fprintf(stderr, "UNKNOWN objv[1] %s\n", ObjStr(objv[1])); if (objc > 1 && ((*methodName) == '-' || (unknownObj && objv[0] == unknownObj))) { int length; + tailMethodObj = objv[1]; if (Tcl_ListObjLength(interp, objv[1], &length) == TCL_OK) { if (length > 1) { Tcl_ListObjIndex(interp, objv[1], length - 1, &tailMethodObj); - } else { - tailMethodObj = objv[1]; - } - } else { - /* The first ("method") argument to unknown is an invalid list, yet a valid message */ - fprintf(stderr, "UNKNOWN2 objv[1] %s\n", ObjStr(objv[1])); - tailMethodObj = objv[1]; + } } } - fprintf(stderr, "tail %s MethodName(tail) %s\n", ObjStr(tailMethodObj), MethodName(tailMethodObj)); result = NsfPrintError(interp, "%s: unable to dispatch method '%s'", ObjectName_(object), (tailMethodObj != NULL) ? MethodName(tailMethodObj) : methodName); } - + /* * Reset interp state, unknown has been fired. */ rst->unknown = 0; - + return result; } Index: tests/methods.test =================================================================== diff -u -r3c1482d9e1f80f0216250f5debade5d8edb1b17e -r3ed6440e2cbe7612bba89469b3c44c376d857338 --- tests/methods.test (.../methods.test) (revision 3c1482d9e1f80f0216250f5debade5d8edb1b17e) +++ tests/methods.test (.../methods.test) (revision 3ed6440e2cbe7612bba89469b3c44c376d857338) @@ -230,6 +230,60 @@ ? {o eval :foo} "::o: unable to dispatch method 'foo'" } +nx::test case colon-unknown { + set o [nx::Object new { + :object method foo {a b c args} { return [current method]-ok } + + ## Expansion to valid method calls (messages) + :object method expand-non-empty-list-1 {} { + {*}[list :foo 1 2 3 4 5 6]; + } + :object method expand-non-empty-list-2 {} { + : {*}[list foo 1 2 3 4 5 6]; + } + :object method expand-self-call-1 {} { + {*}[list :]; + } + :object method expand-self-call-2 {} { + : {*}[list]; + } + + ## (Non-)expansion & unknown + :object method expand-unknown-1 {} { + :{*}[list foo 1 2 3 4 5 6]; # no expansion, yielding invalid list as method name + } + :object method expand-unknown-2 {} { + :{*}[list]; # no expansion, yielding invalid list as method name + } + :object method expand-unknown-3 {} { + :{*}; # no expansion, yielding invalid list as method name + } + :object method expand-unknown-4 {} { + :{*}{}; # no expansion, yielding invalid list as method name + } + :object method expand-unknown-5 {} { + :{\}}; # yet another invalid list (no expansion op) + } + }] + + ? [list $o expand-non-empty-list-1] "foo-ok" + ? [list $o expand-non-empty-list-2] "foo-ok" + ? [list $o expand-self-call-1] $o + ? [list $o expand-self-call-2] $o + + # + # Keep unknown messages compatible with Tcl's 'invalid command' + # messages in the cases below, e.g.: + # + # proc =foo {args} {;}; ={*}[list foo 1 2 3 4 5 6] + # + ? [list $o expand-unknown-1] "$o: unable to dispatch method '{*}foo 1 2 3 4 5 6'" + ? [list $o expand-unknown-2] "$o: unable to dispatch method '{*}'" + ? [list $o expand-unknown-3] "$o: unable to dispatch method '{*}'" + ? [list $o expand-unknown-4] "$o: unable to dispatch method '{*}{}'" + ? [list $o expand-unknown-5] "$o: unable to dispatch method '{\}}'" +} + nx::test case mixinguards { # define a Class C and mixin class M nx::Class create C