Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 4712a9be3002709d34f55ba3aa595449d4e7c0f5b9a74c882eebaf83fb038f5e
Ticket: b55589c55b36c9908294e1f9631ea98ca98d6ae9
the lset command cannot change the size of a list
User & Date: rbucker on 2023-02-17 14:41:26
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-markdown"
  4. comment changed to:
    The doc says...
    
    The integer appearing in each index argument must be greater than or equal to zero. The integer appearing in each index argument must be strictly less than the length of the corresponding list. In other words, the lset command cannot change the size of a list. If an index is outside the permitted range, an error is reported.
    
    my test case:
    
    ```
    set abc [list a b c];
    puts "${abc}";
    puts "[lset abc 2 x]";
    
    
    # error cases
    puts "[catch {lset abc -2 x} res] res:$res";
    puts "[llength ${abc}]";
    puts "[catch {lset abc 14 x} res] res:$res";
    puts "[catch {lset abc 13 x} res] res:$res";
    puts "[catch {lset abc 12 x} res] res:$res";
    
    puts "[catch {lset abc 3 x} res] res:$res";
    puts "[llength ${abc}]";
    puts "[catch {lset abc 4 x} res] res:$res";
    puts "[llength ${abc}]";
    ```
    
    returns
    
    ```
    a b c
    a b x
    1 res:list index out of range
    3
    1 res:list index out of range
    1 res:list index out of range
    1 res:list index out of range
    0 res:a b x x
    4
    0 res:a b x x x
    5
    ```
    
    Notice that when the index is exactly the length of the list that the newvalue is appended to the list, however, the doc says "STRICTLY" cannot change the size of the list.
    
  5. foundin changed to: "8.6"
  6. is_private changed to: "0"
  7. login: "rbucker"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "f1cbdd73b57f5bd1c724efe36f7caf833f36d58f"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "rbucker"
  14. subsystem changed to: "14. List Object"
  15. title changed to: "the lset command cannot change the size of a list"
  16. type changed to: "Bug"