Skip to content
Tcl Source Code Check-in [b00991eb89]
Login

Check-in [b00991eb89]

Overview
Comment:Let’s address the point: "Variants with the same form—if multiple equally strict variants are applicable, trigger an error; the error message should suggest `{variant}value` and `set {S}v(variant) value`, while ensuring the deduction defaults to the strictest variant." This is now implemented: v15m is included in `typeparse.zip`. The item has been marked as complete in the project schedule and noted in `noyau/LISEZMOI.md` as well as `doc/ANNOTATIONS.fr.md` (section 8; it has also been removed from section 17). Regarding the error message: The deduction logic selects the strictest variant (e.g., given `{int}i` and `{string}s`, the value `5` resolves to `i`, as before). If multiple equally strict variants are applicable, an error is raised: `set {A}v 5` ;# the value "5" fits variants `i` and `j` of `A` equally: write `{i}5` or `set {A}v(i) 5` The suggested syntax `set {A}v(i) 5` includes the variable name and only appears when an assignment is made directly to the sum type itself. In the context of a list or a product, the message simply suggests `{i}7`. The same logic applies to variants that have no defined precedence relative to one another (e.g., `{P}p` and `{Q}q` with `{1 2}`). For identical anonymous variants (e.g., `{int}`, `{int}`), since there are no labels to reference, the message instructs the user to "name the variants to choose one." A discovery made along the way: With this error check in place, many previously valid cases began to fail. In v15, these cases had passed because the chosen variant was silently discarded, defaulting back to `i`. This occurred in scenarios such as: assignments within a list (`set {list.A}L $v`); assignments within a product (`set {R}r $v 1`); operations like `incr v`, `set v 8`, `lset`, or `set L(0) …`; and type casts—such as `A {j}5` or even `B {s}5`—which previously resolved to `B.i`. I have also addressed these instances of lost information: Lists and products: an element or field whose content alone does not uniquely identify its variant now retains its annotation. (The validation process was already re-reading this information.) Type casts: the label beneath the type of a sum now explicitly names the variant. A design decision to confirm: for a modification (e.g., `set v 8`, `incr v`, `set L(0) 4`, `lset L 0 9`, `set r(a) 7`), I have configured it to preserve the current variant when multiple variants are equally valid. Otherwise, an operation like `incr v` on an `A.j` would trigger an error. If you would prefer to have an error in all such cases—based on the principle that "a modification is a computation"—this can be changed by removing four lines of code. Tests against v15: The same differences as before, plus `t65`, with no other changes. All expected `.out` outputs pass. The Tcl tests—`set`, `var`, `upvar`, `lset`, `list`, `lindex`, `append`, and `incr`—result in 1,234 successes out of 1,251, with 17 skipped and zero failures (across both trees). `valgrind` reports no issues for the new test cases. New test added: `t66_variantes_meme_forme`.
Timelines: family | ancestors | descendants | both | tip-764_tcl90
Files: files | file ages | folders
SHA3-256: b00991eb89224ca42b0fccc61cd6cc5d35183d018737f6e46713c5f614755a88
User & Date: Florentis on 2026-10-23 11:07:57.671
Other Links: branch diff | manifest | tags
Context
2026-10-23
11:20
Conversion rules between variants are now in place: this is version v15n, found in typeparse.zip. t... check-in: 582865c204 user: Florentis tags: tip-764_tcl90
11:07
Let’s address the point: "Variants with the same form—if multiple equally strict variants are ap... check-in: b00991eb89 user: Florentis tags: tip-764_tcl90
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
Changes