Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: c9f0351c638d18a368aecf2effb8beca3ad1c742920269eff9ef337c5181c0cd
Ticket: 3019348fffffffffffffffffffffffffffffffff
Nested lset can modify list on error
User & Date: apnadkarni on 2026-10-17 16:54:54
Changes

  1. assignee changed to: "apnadkarni"
  2. closer changed to: "nobody"
  3. comment changed to:
    My expectation is that when lset throws an error, it won't modify the list.  However, the following script shows otherwise:
    
    % set foo {}
    % lset foo 0 0 x
    x
    % lset foo 0 1 x
    {x x}
    % lset foo 1 0 x
    {x x} x
    % lset foo 1 1 x
    {x x} {x x}
    % lset foo 2 1 x
    list index out of range
    % set foo
    {x x} {x x} {}
    % lset foo 3 0 x
    {x x} {x x} {} x
    % lset foo 3 1 x
    {x x} {x x} {} {x x}
    
    The command [lset foo 2 1 x] throws an error but also adds an empty element to the end of the list.
    
  4. login: "apnadkarni"
  5. mimetype: "text/plain"
  6. severity changed to: "Minor"