|
2020-01-21
| ||
| 09:14 | • Ticket [eabb2f5613] Tcl parser UB (braces vs. quotes/brackets) status still ... artifact: 77e96a3ec3 user: sebres | |
| 02:03 | • Closed ticket [eabb2f5613]. artifact: 80d37a6909 user: dgp | |
|
2020-01-20
| ||
| 20:19 | • New ticket [eabb2f5613]. artifact: b1498ba8e4 user: sebres | |
Tcl parser UB (braces vs. quotes/brackets)
[catch ...]).
where whole code running "good" if copy&pasted into the shell (then it takes "}" as a options variable, try set \} to see that).
The result is quasi similar "undefined behavior", just compare following:
and
% eval "puts }"
}
% if 1 { eval "puts }" }
extra characters after close-brace
I could fix that, but do not really know how:
% eval "puts \}"
}
% if 1 { eval "puts \}" }
}
- either
eval "puts }"should cause some (parse) error - or
if 1 { eval "puts }" }should avoid an error too (must consider open quotes and square brackets)
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.
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.
This is not a bug. It is just a demonstration of how brace quoting works.
I am aware of that, Don. As well as that using of Tcl_FreeResult is still possible in tcl 8.x. What does not mean it remains.
I wanted just point to a bit unfavorable parsing in some situations.
And a unmatched brace in this Kevin's script [list [catch { a $::depth } result }] ...] was surely a typo, which is not "recognized" by the parser.
Some parse error like unpaired brace could be quite imaginable here (in new version).
Another point is: if one must escape unpaired braces in quotes or square brackets in codes enclosed in braces, why it is not obligorish outside of this codes?