Overview
| Comment: | Error messages now explicitly name the variants (v15k). Additionally, reading from an inactive variant can now succeed; this is a change in behavior that should be verified. The source Reading a variant other than the current one constitutes an explicit cast, according to the specification (§ 10). However, the code was performing the cast from the entire sum type—specifically, from `S` to `string`. Since no rule exists for converting a sum type into one of its constituent variants, the system previously returned the unhelpful error: "unknown way to cast the value from S to string." The fix The cast is now performed based on the value of the current variant: set {S}v {i}5 $v(s) -> 5 (the 5 from variant `i`, read as a `string`) set {U}u {n}3 $u(p) -> the current variant of U is "n", not "p", and its value "3" can't be read as `p` Regarding write operations, there are two scenarios: Writing to a variant changes the variant, as before: `set v(s) abc` results in `S.s`. Writing to a component of an inactive variant is still disallowed, but the error message now provides guidance: set u(p.x) 1 -> the current variant of U is "n", not "p": to change the variant, write the whole value ({p}...) The suggested write operation works: `set u {p}{1 2}` results in `U.p`. Verifications Project tests and examples yield the same results as before, including those for `arduino` and `cstruct`, which utilize sum types. Tests `t35` through `t63` retain their expected outcomes. Update `tclTypePath.c` only (without kernel patch), followed by `maj.sh`. New test case: `t64_variante_inactive`. The v15k section in kernel/README.md. The “sum” line in the French documentation’s path table, now completed. I removed the bullet point from § 17 and checked off the corresponding item in the planning document. For your approval: previously, $v(s) on an {i}5 would always fail. Now, it returns 5, in accordance with the explicit cast rule. If you would prefer that reading an inactive variant always result in an error—with the same error message—it’s just a single line that needs changing. |
|---|---|
| Timelines: | family | ancestors | descendants | both | tip-764_tcl90 |
| Files: | files | file ages | folders |
| SHA3-256: |
eb4d87204c8a07bc4611a6e5c3b4471e |
| User & Date: | Florentis on 2026-10-23 10:32:49.604 |
| Other Links: | branch diff | manifest | tags |
Context
|
2026-10-23
| ||
| 10:45 | [x] set {paire}s {aut.nom}x : dedicated message "aut.nom names a field of aut, not of paire" (Claude... check-in: be20ecadc1 user: Florentis tags: tip-764_tcl90 | |
| 10:32 | Error messages now explicitly name the variants (v15k). Additionally, reading from an inactive varia... check-in: eb4d87204c user: Florentis tags: tip-764_tcl90 | |
| 10:16 | I have implemented points 1 and 2 in tclTypeParse.c; anonymous sum variants remain permitted, as pre... check-in: 78c932af24 user: Florentis tags: tip-764_tcl90 | |
Changes
Modified generic/tclTypePath.c
from [5adadd5e16]
to [91a81dcc6a].
[diff]
Modified typeparse/doc/ANNOTATIONS.fr.md
from [d62a5e2efe]
to [d0a6466429].
[diff]
Modified typeparse/noyau/LISEZMOI.md
from [a27f370d1d]
to [732cb388fd].
[diff]
Modified typeparse/tclTypePath.c
from [5adadd5e16]
to [91a81dcc6a].
[diff]
Added typeparse/tests_tclsh/t64_variante_inactive.out version [d670535bb7].
Added typeparse/tests_tclsh/t64_variante_inactive.tcl version [dd48601d1d].