When Tcl_NRCmdSwap() is called, there
is no call to TEOV_PushExceptionHandlers(),
so no handling of toplevel exception and
no appending to -errorinfo when TCL_ERROR
arises.
This seems to be the right feature set
for [namespace import]ed commands, which
is the sole Tcl_NRCmdSwap() caller in
our sources.
It's less clear that other T_NRCS() callers
want the same thing. At least the docs
need to be clearer about it.
I call a possible doc bug: T_NCRS is meant to do precisely what imports do, replace the original command with a new one. In particular, the swap should not add new exception handlers - exceptions are treated only by the original command, not by the replacement.
If both the original and the replacement commands are meant to handle exceptions the proper approach is to mimic what aliases do: eval a new objc/objv.
Thanks for commenting miguel.
The matter arises as I look into
Tcl Bug 2486550. TclObjInvoke()
directly calls a cmdPtr->objProc
just like the InvokeImportedCmd()
used to do. Since T_NCRS() solved
one, it's a candidate to solve the
other as well. But TOI does include
code to append to the -errorinfo .
If TclNREvalObjv() were revised
so that a T_NCRS() call still
tried a TEOV_PEH() call before
skipping the command resolution
stuff, then InvokeImportedCmd()
could still run exactly as it
does now by just passing the
TCL_EVAL_NOERR flag, and TOI
could use the same routine
not passing it.
Is there a reason this is assigned to me?
I committed the NRE documentation while miguel
was _hors de combat_, but I think he'd be a
better choice to examine it first.
when I first filed, I assumed
miguel was still incommunicado,
and also assumed this was basically
a docs bug. Neither is turning
out to be completely true.
status?
dgp's proposed solution sounds good.
See branch bug-2502002 for work in progress.