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: |
b00991eb89224ca42b0fccc61cd6cc5d |
| 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
Modified typeparse/doc/ANNOTATIONS.fr.md
from [78e9843f1b]
to [e694d22994].
[diff]
Modified typeparse/noyau/LISEZMOI.md
from [ea84fffa49]
to [c4af277859].
[diff]
Modified typeparse/tclAnnotObj.c
from [72fb27ea9b]
to [22094209f0].
[diff]
Modified typeparse/tclTypePath.c
from [91a81dcc6a]
to [6b228cbf41].
[diff]
Modified typeparse/tclTypedVar.c
from [6c7b9c8a53]
to [cdb7dd777a].
[diff]
Modified typeparse/tclTypes.c
from [96594d1658]
to [343cc86e41].
[diff]
Modified typeparse/tclTypes.h
from [7045111ace]
to [c1f08167ed].
[diff]
Added typeparse/tests_tclsh/t66_variantes_meme_forme.out version [4670cf38a1].
Added typeparse/tests_tclsh/t66_variantes_meme_forme.tcl version [99612301db].