Artifact d670535bb772c2330c884192dda440604cc4f25613b17df6a8aebfc46b163530:
- File typeparse/tests_tclsh/t64_variante_inactive.out — part of check-in [eb4d87204c] at 2026-10-23 10:32:49 on branch tip-764_tcl90 — 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. (user: Florentis, size: 575) [annotate] [blame] [check-ins using] [more...]
v(i) active 0 5 v(s) inactive 0 5 u(p) inactive 1 the current variant of U is "n", not "p", and its value "3" can't be read as pt u(p.x) inactive 1 the current variant of U is "n", not "p", and its value "3" can't be read as pt u(n) active 0 3 v(zz) inconnue 1 S has no variant "zz" set v(s) abc (écrit) 0 abc S.s set u(p.x) 1 1 the current variant of U is "n", not "p": to change the variant, write the whole value ({p}...) abc S.s 1 2 U.p 1