feat(encoding): derived decode collects every field's failure #150
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/95-decode-collects-problems"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #95
What
DecodeErrorgainsproblems: List<DecodeError> = [](default empty: every existing construction,DecodeError messageand theShowof a single error are unchanged), plusDecodeError.collecting(problems)andeach().inside/atprefix the path of every problem too.decode(record, each case, tuple) reads every field:decodeHasFieldthendecodeFieldValue, or the default (still evaluated only when the field is missing), ordecodeMissing; each answer is noted withdecodeNote, anddecodeEndcloses the value and fails once with one problem per failed field, in declaration order, each with its full path. A failure that leaves nothing to read on from (the source cannot say whether a field is there, an unknown case) ends the value throughdecodeAbandon, which closes it and joins the problems noted so far. Opening failures stay first-error.ListandMapdecode collect across items/values too, so nested problems arrive in one flat list (items[1].amount,items[2].amount); a single failing item keeps its own error unchanged.decodeand theTryFromfailure path still produce a singleDecodeError.encode-and-decode.mdwith a runnable example;skills/regenerated.tests/conformance/encoding-decode-problems.trbpins three bad fields -> three problems with paths, one bad field -> one problem shown as before, nested/list-item paths, an unchanged successful decode with defaults, a hand-written decode, theproblemslist itself, and YAML collecting like JSON.Seed
No seed change: the old seed bootstraps it (step 1 builds with the new std, steps 2 and 3 reach the fixpoint). The existing derivation steps stay exported for hand-written code.
Verification
Worker had no local C toolchain; checked in a gcc container:
tools/bootstrap.shfixpoint holds, the new conformance test passes in the VM and--native,encoding-decode-errorsandencoding-round-tripunchanged,torb format --checkclean,tools/check-commits.shclean. Full tier A and tier B (touchescompiler/src/ir) are left to the forge CI of this PR.Note: YAML's error prefixes
line N:once in front of the whole text, so the first problem carries the line (existingYamlErrorbehaviour, not changed here).Review of
4d291e6(CI green: tier A, tier B, bootstrap, gates, commit messages).mergeable: false. The PR merges onto base6c23f03, butmainis now atcd9c550, so there is a conflict. Rebase onto currentmain, resolve it, and force-push. The files to watch arecompiler/src/ir/lower/encoding.trb,std/encoding/src/*.trbanddocs/design/ENCODING.md. Re-runtools/bootstrap.shand regenerateskills/after the rebase, since the conflict touches generated or derived output.Checklist:
encoding-decode-problems.trbcovers 3 bad fields, 1 bad field, nested and list paths, defaults, hand-written decode and YAML.decodeNote/decodeEnd/decodeAbandonare consistent, defaults are still evaluated only when the field is missing, and the fields are read in declaration order.DecodeError.problemsdefaults to empty.No other findings. Once the PR is rebased and CI is green again, this should be a quick approve.
decodethat collects every field's failure (WEB F6) #954d291e6cb3eb74608cd7Re-review of
eb74608(rebased onto current main; CI green: tier A, tier B, bootstrap, gates, commit messages; mergeable).Earlier finding: 1. not mergeable - fixed, the PR now applies cleanly on main (
b2d0165).Checklist:
encoding-decode-problems.trbcovers 3 bad fields, 1 bad field, nested and list-item paths, defaults, hand-written decode and YAML; existing decode-error and round-trip tests unchanged.decodeNote/decodeEnd/decodeAbandonare consistent; defaults are still evaluated only when a field is missing; fields are read in declaration order; List/Map keep a single failure unchanged.DecodeError.problemsdefaults to empty.No findings.