Artifact 86ef4d0aefbe2bd08f5a3dc8b91b95998571a8930c91b25f2d2244a721e34600:
- File typeparse/tests_tclsh/t64_variante_inactive.tcl — part of check-in [43c57f18b6] at 2026-11-04 08:32:02 on branch tip-764_tcl90 — What v16n introduces: `type is {disjoint?}S` returns the pairs of variants that can accept the same value; it returns nothing if the sum is disjoint. `type is {strict?}S` is also available. `type def {-strict}S`: the variant is never inferred (guessed). A "bare" value is rejected: "value 5 names no variant of the strict sum S: write `{i:}value` or `{S.i}value`." Accepted forms include: an already-typed value, a label such as `{i:}` or `{S.i}`, or a type cast like `S.i`. A variant literal is identified by its value, and when stored in a typed variable, the current variant is preserved. `type def {-deduce}S` retains the previous behavior: the strictest variant takes precedence. Warning: An overlapping sum defined without any options will trigger a message on `stderr` suggesting either `{-deduce}` or `{-strict}`. A disjoint sum will not trigger such a message. Multiple options: `{-compact, -strict}` can be used within the annotation syntax. The structure is flattened (e.g., `{-a.(b=1, c=2)}` becomes `-a.b=1` and `-a.c=2`), meaning sub-option syntax is supported. Currently, no `type def` options utilize this; for instance, `{-strict.x=1}` will result in a clear error message. (user: Florentis, size: 796) [annotate] [blame] [check-ins using]
# t64 : lire une variante inactive : cast de la valeur courante, ou message qui nomme # les deux variantes ; écrire dans une variante inactive : message qui guide. type def {-deduce}S {{int}i, {string}s} type def pt {{int}x; {int}y} type def U {{pt}p, {int}n} set {S}v {i:}5 set {U}u {n:}3 proc t {l s} { set rc [catch {uplevel 1 $s} m]; puts [format "%-30s %s %s" $l $rc $m] } t "v(i) active" {set v(i)} t "v(s) inactive" {set v(s)} t "u(p) inactive" {set u(p)} t "u(p.x) inactive" {set u(p.x)} t "u(n) active" {set u(n)} t "v(zz) inconnue" {set v(zz)} t "set v(s) abc (écrit)" {set v(s) abc; list $v [type get $v]} t "set u(p.x) 1" {set u(p.x) 1} set {S}v {i:}5 set v {S.s}abc; puts "$v [type get $v]" set {U}u {n:}3 set u {U.p}{1 2}; puts "$u [type get $u] $u(p.x)"