#3380 [::unknown] and alias targets (TCL_EVAL_INVOKE)

obsolete: 8.4.12
closed-fixed
5
2006-03-06
2006-03-06
Don Porter
No

Here's a test case illustrating
a problem with handling of
TCL_EVAL_INVOKE flag value in
TclEvalObjvInternal:

test parse-8.12 {Tcl_EvalObjv procedure, TCL_EVAL_INVOKE} {
set ::auto_index(noSuchCommand) {
proc noSuchCommand {} {lappend ::info global}
}
set ::auto_index(::[string trimleft [namespace
current]::test_ns_1::noSuchCo
mmand :]) [list \ proc [namespace
current]::test_ns_1::noSuchCommand {} {
lappend ::info ns
}]
catch {rename ::noSuchCommand {}}
set ::slave [interp create]
$::slave alias bar noSuchCommand
set ::info {}
namespace eval test_ns_1 {
$::slave eval bar
}
namespace delete test_ns_1
interp delete $::slave
catch {rename ::noSuchCommand {}}
set ::info
} global

The [::unknown] command is called when
Tcl cannot resolve a command name. The
default ::unknown proc defined in init.tcl
attempts to [auto_load] a command so
that the unresolved command name will resolve
in future attempts. While performing thi
task, the ::unknown proc assumes that the
resolution context is given by:

[uplevel 1 {::namespace current}]

When the command name being resolved
is getting eval'd because it is the
target of an interp alias, this assumption
is not true. TCL_EVAL_INVOKE forces
resolution in ::, but swaps back to
caller context before ::unknown is called.

As the test demos, this can cause the wrong
command to be auto-loaded, and evaled.

Discussion

  • Don Porter

    Don Porter - 2006-03-06

    Logged In: YES
    user_id=80530

    Attached patch fixes
    core-8-4-branch, while
    simplifying TEOvI at
    the same time.

     
  • Don Porter

    Don Porter - 2006-03-06

    Logged In: YES
    user_id=80530

    revised patch

     
  • Don Porter

    Don Porter - 2006-03-06
     
  • Don Porter

    Don Porter - 2006-03-06
     
  • Don Porter

    Don Porter - 2006-03-06

    Logged In: YES
    user_id=80530

    corresponding patch for HEAD

     
  • Don Porter

    Don Porter - 2006-03-06

    Logged In: YES
    user_id=80530

    patches committed.

     
  • Don Porter

    Don Porter - 2006-03-06
    • status: open --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks