Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b1498ba8e4eaeb44469cfff5e6e23d3a4fba91a069a3961db96463d6cea31d00
Ticket: eabb2f5613b6996eb80bc73f903a8da139c78dbd
Tcl parser UB (braces vs. quotes/brackets)
User & Date: sebres on 2020-01-20 20:19:19
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    Today I tried to find some sporadic issue, so trying to start last code piece of [5adbede0722cb22f] multiple times (using timerate call) ends with "extra characters after close-brace" (because of "}" in catch in <code>[catch ...]</code>).
    where whole code running "good" if copy&pasted into the shell (then it takes "}" as a options variable, try <code>set \}</code> to see that).
    
    The result is quasi similar "undefined behavior", just compare following:
    <code><pre style=padding:10pt><b style="color:green">% eval "puts }"
    }</b>
    <b style="color:red">% if 1 { eval "puts }" }
    extra characters after close-brace</b>
    </pre></code>
    and
    <code><pre style=padding:10pt><b style="color:green">% eval "puts \}"
    }
    % if 1 { eval "puts \}" }
    }</b>
    </pre></code>
    I could fix that, but do not really know how:
    <ol>
    <li>either <code>eval "puts }"</code> should cause some (parse) error</li>
    <li>or <code>if 1 { eval "puts }" }</code> should avoid an error too (must consider open quotes and square brackets)</li>
    </ol>
    The decision is something for a syntax evangelists (@TCT).
    
    Anyway if parser works differently on certain circumstances (e. g. some code becomes enclosed or copied in other code within braces) - it is pretty good definition of UB.
    
    In my opinion the parser shall to work always in the same way... because it may be obvious on some small code pieces, but can cause real burning brain on some unpaired brace in large codes with many nested quotes/brackets/braces.<br/>
    Especially if code is created "dynamically" (some template engine mixing Tcl with some other lang, like html), so you've to look on some interim result of pre-processor to find the issue.
    
  5. foundin changed to: "any"
  6. is_private changed to: "0"
  7. login: "sebres"
  8. priority changed to: "5 Medium"
  9. resolution changed to: "None"
  10. severity changed to: "Severe"
  11. status changed to: "Open"
  12. submitter changed to: "sebres"
  13. subsystem changed to: "45. Parsing and Eval"
  14. title changed to: "Tcl parser UB (braces vs. quotes/brackets)"
  15. type changed to: "Bug"