Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: cffd6b1618837dcc407260dfd7e66e2aafca03a7
Ticket: fbc88fb645c5b2f47f16cd0e167ef47de081f212
[variable] doesn't follow variable resolution rules
User & Date: emiliano on 2017-05-30 20:56:02
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    The [variable] command, when used inside a procedure, doesn't follow the variable resolution rules as stated in namespace(n):
    "Variable names are always resolved by looking first in the current namespace, and then in the global namespace"
    When using relative names, it fails to look in the global namespace.
    In this interactive session, from the global namespace: 
    
    % namespace eval a {variable a "a in [namespace current]"}
    % namespace eval foo {puts $a::a}
    a in ::a
    % namespace eval foo::a {variable a "a in [namespace current]"}
    % namespace eval foo {puts $a::a}
    a in ::foo::a
    % namespace eval foo {proc bar {} {puts $a::a}}
    % foo::bar
    a in ::foo::a
    % namespace delete foo::a
    % foo::bar
    a in ::a
    % namespace eval foo {proc bar {} {variable a::a; puts $a}}
    % foo::bar
    can't access "a::a": parent namespace doesn't exist
    % namespace eval foo::a {variable a "a in [namespace current]"}
    % foo::bar
    a in ::foo::a
    
    the error shown is not expected; it should instead print "a in ::a", same as using $a::a directly inside the proc.
    
  5. foundin changed to: "8.7"
  6. is_private changed to: "0"
  7. login: "emiliano"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "0da21f2649e2f7139a4113668982586168b3d24e"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "emiliano"
  14. subsystem changed to: "07. Variables"
  15. title changed to:
    [variable] doesn't follow variable resolution rules
    
  16. type changed to: "Bug"