Artifact d3886d7499721987b575147740677e46b99270ac217ab7c69f6dbc67a7a7738c:
- File typeparse/tests_tclsh/t60_construction_liste.tcl — part of check-in [a04ace5134] at 2026-10-23 09:26:11 on branch tip-764_tcl90 — The bug has been fixed (v15h). I went a bit further than what was noted in the schedule: instead of rejecting AB(0,1), I made it functional. My response from October 22nd (“0,1 is not a path”) was incorrect: `set {pt}Q(x,y) 1 2` works for a product, so (0,1) is indeed a valid construction path. It simply didn’t work for a list. The root cause Construction via a path—`set {T}v(a,b) x y`—was previously only implemented for products and sums. For any other type, the identifier `AB(0,1)` was treated as an array element; Tcl would create the array `AB` and then fail with a “no such element in array” error. The empty array would remain, causing the subsequent `set {segment}AB $A $B` command to fail as well. The fix A list is constructed by specifying its indices. All indices—from 0 to N-1—must be provided, in any order, as lists have no default values: tcl set {segment}AB(0,1) $A $B ;# {0 0} {4 4} set {segment}S(1,0) {4 4} {0 0} ;# same result set {segment}S(0.x,0.y,1.x,1.y) 1 2 3 4 ;# {1 2} {3 4} Each error now triggers a clear, descriptive message: a missing index: “element 1 of poly is not given: … needs all of them, from 0 to 2”; a duplicate index: “element '0' of poly is assigned more than once”; an invalid index name: “'a' is not an index of poly”; Incorrect number of elements: a segment requires exactly 2 elements, but 3 were provided. A dictionary is constructed via its keys: `set {dict.int}D(a,b) 1 2` results in `a=1, b=2`. Other types are rejected before any variable lookup occurs, meaning nothing is created: `set {int}A(k) 5` -> `can't set "A(k)": a typed variable is a scalar, not an array element;` `a constructor path (k) names fields of products, indices of lists, or` `keys of dictionaries, and 'int' is none of these.` Verifications Compared to v15, the project’s tests and examples remain unchanged, with one exception: the error message for `t52` now mentions lists and dictionaries. Tests `t35` and `t37`, as well as `t55` through `t59`, continue to yield their expected results. On the Tcl side, I ran 12 test files (covering variables, arrays, `set`, `upvar`, `incr`, dictionaries, etc.), totaling 1,515 tests; the only failure—found in `execute.test`—is already among the known failures from v15. Update Two type-related source files, `tclTypePath.c` and `tclTypedVar.c`, with no kernel patch required. Then, `maj.sh` was run. I added the `t60_construction_liste` test and regenerated `t52`. The `v15h` section can be found in `noyau/LISEZMOI.md`, the French documentation includes a paragraph in section 7.1, and the item has been marked as complete in the project schedule. (user: Florentis, size: 2019) [annotate] [blame] [check-ins using]
# t60 : construction par chemin d'une liste (indices) ou d'un dict (clés) ; une variable # typée est un scalaire : set {int}A(k) est refusé sans rien créer. type def point {{double}x; {double}y} type def segment list(2).point set {point}A 0 0; set {point}B 4 4 proc t {l s} { set r [catch {uplevel 1 $s} m]; puts [format "%-40s %s %s" $l $r $m] } t "set {segment}AB(0,1) \$A \$B" {set {segment}AB(0,1) $A $B} t "array exists AB" {array exists AB} t "info exists AB" {info exists AB} t "set {segment}AB \$A \$B" {set {segment}AB $A $B} t "array exists R" {array exists R} t "list.int : set {list.int}L(0,1) 5 6" {set {list.int}L(0,1) 5 6} t "array exists L" {array exists L} proc p {} { catch {set {segment}S(0,1) {0 0} {1 1}} m; list $m [array exists S] [info exists S] } t "dans une procédure" {p} type def poly list.point proc t {l s} { set r [catch {uplevel 1 $s} m]; puts [format "%-44s %s %s" $l $r $m] } t "segment ordre inverse AB(1,0)" {set {segment}S1(1,0) {4 4} {0 0}; list $S1 [type get $S1]} t "trou L(0,2)" {set {poly}S2(0,2) {0 0} {1 1}} t " S2 créé ?" {info exists S2} t "doublon L(0,0)" {set {poly}S3(0,0) {0 0} {1 1}} t "pas un indice L(a,b)" {set {poly}S4(a,b) {0 0} {1 1}} t "segment de 3 : S5(0,1,2)" {set {segment}S5(0,1,2) {0 0} {1 1} {2 2}} t " S5 créé ?" {info exists S5} t "chemin profond 0.x,0.y,1.x,1.y" {set {segment}S6(0.x,0.y,1.x,1.y) 1 2 3 4; list $S6 [type get [lindex $S6 1]]} t "élément invalide" {set {segment}S7(0,1) {0 0} abc} t "dict.int D(a,b)" {set {dict.int}D(a,b) 1 2; list $D [type get $D]} t "dict.int invalide" {set {dict.int}D2(a) x} t "{int}I(k) refusé" {set {int}I(k) 5} t " I créé ?" {info exists I} t "nombre de valeurs" {set {segment}S8(0,1) {0 0}}