Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 20269456049707d2a64e9ef8b401ef591e3050c2a30dbc0b9f4a0b50ca5a7ddd
Ticket: db36fa5122259be74d0ccadd102e076094703052
compiled lindex botches index artihmetic
User & Date: dgp on 2018-03-01 19:10:37
Changes

  1. comment changed to:
    % lindex {a b c} -1-1
    c
    
    Correct answer should be the empty string.
    
    The bytecode compiler for [lindex] tries to
    encode the indices "end", "end-1", .... etc.
    as the immediate bytecode arguments -2, -3, ....
    
    It ignores the possibility that TclGetIntForIndex()
    can return those values as legit index values
    resulting from index arithmetic.  In this example
    the index "-2" is getting interpreted as if it were "end".
    
  2. icomment:
    
    % lrange {a b c} 0-3 0-2
    b c
    
    Same fundamental cause.
    
    traces back to:
    
    https://core.tcl.tk/tcl/info/533a2ba7b7d13364
    
  3. login: "dgp"
  4. mimetype: "text/plain"