Index: generic/nsf.c =================================================================== diff -u -N -r79bca8ba3bc60bdb2bacd88af12a24cad002f409 -r918dad9936cd257821e13fa823ff94e89c3c9ea5 --- generic/nsf.c (.../nsf.c) (revision 79bca8ba3bc60bdb2bacd88af12a24cad002f409) +++ generic/nsf.c (.../nsf.c) (revision 918dad9936cd257821e13fa823ff94e89c3c9ea5) @@ -16987,10 +16987,23 @@ ov[3] = AddPrefixToBody(body, 0, &parsedParam); } + /* + * Check, if the cmd exists already in the namespace. If so, delete it from + * there. + */ + { + Tcl_HashEntry *hPtr = Tcl_FindHashEntry(Tcl_Namespace_cmdTablePtr(nsPtr), methodName); + if (hPtr != NULL) { + NSDeleteCmd(interp, nsPtr, methodName); + //fprintf(stderr, "... DELETE preexisting cmd %s in ns %s\n", methodName, nsPtr->fullName); + } + } + //Tcl_PushCallFrame(interp, (Tcl_CallFrame *)framePtr, nsPtr, 0); /* * Create the method in the provided namespace. */ + result = Tcl_ProcObjCmd(NULL, interp, 4, ov); if (likely(result == TCL_OK)) { Index: tests/alias.test =================================================================== diff -u -N -r275da34d3d7a874a451eced58242b738c8a37d1a -r918dad9936cd257821e13fa823ff94e89c3c9ea5 --- tests/alias.test (.../alias.test) (revision 275da34d3d7a874a451eced58242b738c8a37d1a) +++ tests/alias.test (.../alias.test) (revision 918dad9936cd257821e13fa823ff94e89c3c9ea5) @@ -377,7 +377,7 @@ ::nsf::method::alias ::C BAR ::foo # AliasDelete in AddObjectMethod -? {info exists ::nsf::alias(::o,BAR,1)} 1 +? {info exists ::nsf::alias(::o,BAR,1)} 1 "delete alias via redefinition of a method" ::o public object method BAR {} {;} ? {info exists ::nsf::alias(::o,BAR,1)} 0