Index: generic/nsf.c =================================================================== diff -u -r42f380056d1453bbdf852086060d2cf5e40155d8 -r392fda7d21bb87b5727efd57ec51d07fcf4547f4 --- generic/nsf.c (.../nsf.c) (revision 42f380056d1453bbdf852086060d2cf5e40155d8) +++ generic/nsf.c (.../nsf.c) (revision 392fda7d21bb87b5727efd57ec51d07fcf4547f4) @@ -24993,6 +24993,8 @@ nonnull_assert(methodName != NULL); nonnull_assert(tcd != NULL); + /*fprintf(stderr, "AliasRefetch %s\n", methodName);*/ + defObject = (tcd->class != NULL) ? &(tcd->class->object) : object; /* @@ -25083,7 +25085,7 @@ AliasCmdClientData *tcd = (AliasCmdClientData *)Tcl_Command_objClientData(cmd); assert(tcd != NULL); - + /*fprintf(stderr, "AliasDereference %s epoch %d\n",methodName, Tcl_Command_cmdEpoch(tcd->aliasedCmd));*/ if (unlikely(Tcl_Command_cmdEpoch(tcd->aliasedCmd) != 0)) { /*fprintf(stderr, "NsfProcAliasMethod aliasedCmd %p epoch %p\n", @@ -26334,13 +26336,16 @@ newTargetObject = NsfGetObjectFromCmdPtr(cmd); if (oldCmd != NULL) { - - NSDeleteCmd(interp, nsPtr, methodName); -#if 0 - //fprintf(stderr, "... DELETE preexisting cmd %s in ns %s\n", methodName, nsPtr->fullName); - +#if 1 + /* + * Old solution, leasds to a broken regression test with Tcl 8.7a1. + * However, using Tcl_DeleteCommandFromToken() leads to a crash also with + * earlier solutions when defining recursive aliases. + */ NsfObject *oldTargetObject; + /*fprintf(stderr, "... DELETE preexisting cmd %s in ns %s\n", methodName, nsPtr->fullName);*/ + oldTargetObject = NsfGetObjectFromCmdPtr(oldCmd); /* fprintf(stderr, "oldTargetObject %p flags %.6x newTargetObject %p\n", oldTargetObject, (oldTargetObject != NULL) ? oldTargetObject->flags : 0, newTargetObject);*/ @@ -26357,6 +26362,9 @@ assert(oldTargetObject->refCount > 0); AliasDeleteObjectReference(interp, oldCmd); } + +#else + Tcl_DeleteCommandFromToken(interp, oldCmd); #endif } Index: tests/alias.test =================================================================== diff -u -r52af84c2682d91994f00f6f1cfdf7e9f5fda0a62 -r392fda7d21bb87b5727efd57ec51d07fcf4547f4 --- tests/alias.test (.../alias.test) (revision 52af84c2682d91994f00f6f1cfdf7e9f5fda0a62) +++ tests/alias.test (.../alias.test) (revision 392fda7d21bb87b5727efd57ec51d07fcf4547f4) @@ -792,6 +792,7 @@ ? [list [:] public object alias foo $handle] "::o::foo" } # at runtime, we get an exception + puts stderr ====== ? {o foo} {target "::o::foo" of alias foo apparently disappeared} # test indirect case