Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b903551bcaa2427da9e295b093fe6b45c4735e3b83ea38d8438859b7f4723501
Ticket: 63806646d2436e674070c90bd3e89e1cbc1c0edd
Cannot create array in namespace if it already exists in base
User & Date: jal_frezie on 2024-09-09 15:47:05
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-plain"
  4. comment changed to:
    If an array exists in the base namespace, then you add elements to it in a child namespace, they are added to the base namespace version only. Trying to read the array in the child namespace reads the base namespace version.
    On the other hand if you create the array in the child namespace, then add elements to it in the base namespace, the two arrays remain distinct and each reads correctly in its own namespace.
    
    Example:
    
    $ tclsh
    % info patchlevel
    8.6.14
    % array set foo {qaz 1 wsx 2 edc 3 rfv 4}
    % namespace eval bar {array set foo {tgb 5 yhn 6 ujm 7}}
    % array get foo
    ujm 7 edc 3 qaz 1 tgb 5 rfv 4 wsx 2 yhn 6
    % namespace eval bar {array get foo}
    ujm 7 edc 3 qaz 1 tgb 5 rfv 4 wsx 2 yhn 6
    % array get bar::foo
    % 
    % namespace eval bar {array set xyzzy {tgb 5 yhn 6 ujm 7}}
    % array get xyzzy
    % namespace eval bar {array get xyzzy}
    ujm 7 tgb 5 yhn 6
    % array set xyzzy {qaz 1 wsx 2 edc 3 rfv 4}
    % array get xyzzy
    edc 3 qaz 1 rfv 4 wsx 2
    % namespace eval bar {array get xyzzy}
    ujm 7 tgb 5 yhn 6
    % array get bar::xyzzy
    ujm 7 tgb 5 yhn 6
    %
    
  5. foundin changed to: "8.6.14"
  6. is_private changed to: "0"
  7. login: "jal_frezie"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "21e680c66afc6863cbbaf0aa5b26c9e8a4429339"
  10. resolution changed to: "None"
  11. severity changed to: "Severe"
  12. status changed to: "Open"
  13. submitter changed to: "jal_frezie"
  14. subsystem changed to: "21. [namespace]"
  15. title changed to:
    Cannot create array in namespace if it already exists in base
    
  16. type changed to: "Bug"