Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f1fe9fbd5b272c67221cb67dd10e622c1a8e1f45
Ticket: 1546833fffffffffffffffffffffffffffffffff
wrong varname resolution in [namespace upvar]?
User & Date: msofer on 2006-08-25 18:52:11
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Will Duquette reports by mail that varname resolution
    of [namespace upvar] is failing to do the right thing
    in the (non-fully) qualified case. 
    
    <quote>
    Please consider the code:
    
      namespace eval ::cat:: { }
    
      namespace eval dog:: {
          set dogInfo(a) "A"
          set dogInfo(b) "B"
      }
    
      proc ::cat::TestProc {type} {
          if {![info exists ${type}::dogInfo]} {
              error "no such type: \"$type\""
          }
    
          upvar ${type}::dogInfo dogInfo1
          parray dogInfo1
    
          namespace upvar $type dogInfo dogInfo2
    
          parray dogInfo2
      }
    
      ::cat::TestProc dog
    
    What happens when I run this is it prints the content
    of dogInfo1, but then says there is no array dogInfo2;
    [namespace upvar] is failing to alias dogInfo2 to
    ::dog::dogInfo.
    
    Now, the behavior of [namespace upvar] doesn't surprise
    me; since TestProc is in ::cat::, [namespace upvar] is
    presumably trying to alias dogInfo2 to
    ::cat::dog::dogInfo.  That makes sense to me.
    
    [info exists] and [upvar], on the other hand, are
    finding ::dog::dogInfo; this surprises me.  Do lookups
    of partially-qualified variable names fall back to ::
    if the variable isn't found in the current namespace? 
    If so, [namespace upvar] should undoubtedly do the same
    thing.  I must say, I wasn't expecting them to do that,
    though.
    </quote>
    
    
    
  4. foundin changed to: "obsolete: 8.5a5"
  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: "21. [namespace]"
  11. title changed to: "wrong varname resolution in [namespace upvar]"
  12. type changed to: "Bug"