Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ab139a23a5b47382791b66b22d0509e539006e9bb9a0812725b70cf4f0dd2360
Ticket: c0bc269178df938974e19cbe60e69fc0e711da5f
switch -regexp -matchvar -indexvar broken when optional subexpression does not match
User & Date: apnadkarni on 2022-09-20 18:40:42
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-markdown"
  4. comment changed to:
    The third element of m below should be the empty string as the (b)? is not
    matched.
    
    ```
    % switch -regexp -matchvar m -indexvar i ac {
    {(a)(b)?(c)} {puts m:$m; puts i:$i}
    }
    m:ac a ac c
    i:{0 1} {0 0} {-1 -1} {1 1}
    % info patch
    8.7a6
    ```
    
    core-8-6-branch also exhibits this bug.
    
    **However, 8.6.12 shows correct behavior**
    
    ```
    D:\src\ruff\doc\nroff>d:\tcl\magic\bin\tclsh.exe
    % switch -regexp -matchvar m -indexvar i ac {
    {(a)(b)?(c)} {puts m:$m; puts i:$i}
    }
    m:ac a {} c
    i:{0 1} {0 0} {-1 -1} {1 1}
    % info patch
    8.6.12
    ```
    
    So clearly something was broken post-8.6.12 release.
    
  5. foundin changed to: "8.7"
  6. is_private changed to: "0"
  7. login: "apnadkarni"
  8. priority changed to: "5 Medium"
  9. resolution changed to: "None"
  10. severity changed to: "Minor"
  11. status changed to: "Open"
  12. submitter changed to: "apnadkarni"
  13. subsystem changed to: "- New Builtin Commands"
  14. title changed to:
    switch -regexp -matchvar -indexvar broken when optional subexpression does not match
    
  15. type changed to: "Bug"