|
From: Phillip B. <phi...@um...> - 2025-10-24 23:33:47
|
I have an update concerning one behavior and the viability of $(( ... )) as
the expr shorthand syntax - one thing that Eric and I discovered in trying
different testcases is that Tcl 8.6 and Tcl 9.0 differ in how they handle
this Tcl code:
array set {} { (index 99 }
puts $((index)
Tcl 8.6 treats an unescaped (index string as an index value and prints the
value 99.
Tcl 9.0 treats $((index) as an invalid input:
invalid character in array index
while executing
"puts $("
(file "t.tcl" line 4)
In order to extract the expected value from Tcl 9, the '(' character must
be escaped:
% puts $(\(index)
99
Note also that the trailing ')' character is invalid in both 8.6 and 9.0
where both produce this output:
% array set {} { index) 99 }
% puts $(index))
can't read "(index)": no such element in array
% puts $(index\))
99
While both treat (index) as an invalid index, they produce different error
messages:
8.6:
can't read "((index)": no such element in array
9.0:
invalid character in array index
I ran this through fossil bisect, and found that the change came with this
commit:
% fossil info 378e95c3827e07e7
hash: 378e95c3827e07e77edb1ff47768a8b89b79005d 2022-10-04 16:04:29
UTC
parent: e89e02bd39217e034402a429b9241f848b00e674 2022-10-04 15:57:51
UTC
merged-from: 102677d930e6206eaa65329fa6d623eaef009b2b 2022-09-29 19:17:10
UTC
child: 2e1f06b6e01e758aaffbfa9a399eec16e7688c74 2022-10-04 18:25:18
UTC
merged-into: e34bd0f05fa79d65542e0fe45ec3a52df09453e3 2022-10-04 16:06:01
UTC
tags: trunk, main
comment: TIP #465: Change Rule 8 of the Dodekalogue to Cut Some Corner
Cases (user: jan.nijtmans)
Jan, Can you confirm whether the current behavior here is correct for 9.0
- or is it a bug? If it is correct behavior, then it seems that the $((
expression )) syntax is currently guarded from being recognized as valid
syntax at least in this context.
If it is a bug, can you explain the intent of the change?
Fossil bisect shows this set of results going from core-8-6-branch to main
with good marking 8.6 behavior and bad marking 9.0 behavior:
% fossil bisect bad
bisect complete
1 BAD 2025-10-23 13:29:59 fe5a2b815496eee4
2 GOOD 2025-10-01 09:34:18 6f4ed276049067f2
4 BAD 2023-04-12 18:19:37 0d197907c6441328
7 BAD 2022-12-16 10:25:02 67c049ff94ddd48f
8 BAD 2022-11-01 16:13:26 05e443d1725ae9ae
9 BAD 2022-10-11 15:55:06 0cd124939e1894c0
11 BAD 2022-10-08 15:43:40 58f6cbaca1610f18
12 BAD 2022-10-06 10:15:49 ed075af7b197faa6
13 BAD 2022-10-04 22:05:19 5a5bf81d4c384f25
14 BAD 2022-10-04 18:25:18 2e1f06b6e01e758a
15 BAD 2022-10-04 16:04:29 378e95c3827e07e7 CURRENT
10 GOOD 2022-10-04 15:57:51 e89e02bd39217e03
6 GOOD 2022-09-19 14:06:59 0b9810772d261993
5 GOOD 2021-07-23 10:08:35 2e62fe9b610ddccd
3 GOOD 2019-06-28 22:43:10 309d50a740952c04
Phil
|