Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 76aeaf831985ac207b94b1bc45ad55fcf209f54d
Ticket: 1590483fffffffffffffffffffffffffffffffff
alias can break [uplevel 1 [info level 0]] idiom
User & Date: msofer on 2006-11-04 14:08:29
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    The idiom 
      uplevel 1 [info level 0]
    to cause a renewed call to the same proc can be broken
    by interp aliases:
    
     mig@ice:/tmp$ cat /tmp/test
     set res {}
     proc x {} {
        if {![llength $::res]} {
            set ::res [list [info level 0] :: [uplevel 1
    [info level 0]]]
        } else {
            return ::
        }
     }
     namespace eval a {
        proc x {} {return ::a}
     }
     interp alias {} y {} x
     namespace eval a y
     puts $res
    
     mig@ice:/tmp$ /home/CVS/tcl8.3.4/unix/tclsh test
     x :: ::a
    
    In order for it to break
     1. the alias target is not fully qualified
     2. the alias target is shadowed in the namespace from
    which the alias is invoked
    
    It is relatively easy to fix this: as interp aliases
    are always looked up in the global namespace anyway,
    the target could be fully qualified at alias creation
    time. This would also simplify TEOVI, allowing to
    remove all the namespace gymnastics performed by
    TCL_EVAL_INVOKE. The only change seen by current
    scripts would be in error traces, and in the actual
    return of [info level n] (now fully qualified).
    
  4. foundin changed to: "obsolete: 8.4.15"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "msofer"
  10. subsystem changed to: "45. Parsing and Eval"
  11. title changed to: "alias can break [uplevel 1 [info level 0]] idiom"
  12. type changed to: "Bug"