Repository navigation
feat: check records, variants with fields and match (stage 11a) - #94
Merged
Merged
Conversation
Stage 11 lands records, variants with fields and match first. Write the expected outcomes before the compiler code, with planted faults: a field that overflows without its requires, labels that bind the other field, an arm's sum that overflows, and a quantifier that ignores a variant. The rejections cover exhaustiveness, catch-alls, repeated and missing variants, positional bindings for several fields, missing labels and fields, shadowing, recursive types, lists that hold integers, and machines that hold structured data. Refs #83
Stage 11's target needs a version as a record and pre-release identifiers as variants with fields. Records and variants become SMT-LIB datatypes. A match is a chain of tests on the value's variant, and each name an arm binds becomes the field it stands for, so obligations inside an arm hold under its test alone. A parameter's integers and lists inside a record or variant are assumed in range, as a parameter's are. Normalization names records and fields by position, so a rename changes no identity. The receipt moves to version 5: a record type, and values with fields decoded by name. accord build refuses structured data until its TypeScript output lands, and machines can't hold it yet. Refs #83
The review materials check the receipt contract they read, and receipt 5 adds records and variants with fields, which no card uses. The cards and packets are unchanged; only the hashes of the two scripts move. Refs #83
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slice 11a of stage 11 (#83): records, variants with fields and
match, per syntax decisions 8 to 10. The conformance cases come in their own commit, before the compiler code.What it adds
record Name { field: Type, … }, builtName { field: value, … }with every field named, and read withvalue.field.Below(limit: i64), built like a call. Labels are optional for one field and required for more.match value { | Pattern => result … }withdecide's rows, in code and in specifications._binds nothing.==compares records and variants field by field.Encoding. Records and variants are SMT-LIB datatypes, declared together. A
matchis a chain of tests on the variant, and each binding becomes the field it stands for, so an arm's arithmetic, calls and indexes carry obligations under that arm's test alone. The integers and lists inside a record or variant are assumed in range, as a parameter's are. Normalization names recordsR0and fieldsx0by position, so a rename changes no identity.Decisions taken within the slice
recordtype kind; a variant with fields is{"variant", "fields"}, and a record is an object of its fields. This follows stage 10's 3 → 4 bump._for the ones it doesn't need.accord buildrefuses records, variants with fields andmatchuntil 11g.Verification
cargo fmt --all --checkpasses, andcargo clippy --workspace --all-targets --locked -- -D warningsis clean.cargo test --workspace --lockedwith the pinned solvers on Windows: all pass, and the 1 ignored test was already ignored.accord buildrefuses structured data.Not established:
scripts/check-*.shintegrations weren't run. The TypeScript cases still match their expected output byte for byte.Risk note
Mostly a two-way door: a language addition behind conformance cases. The one-way part is the receipt schema moving to version 5, which is unstable until the first release. Blast radius: existing programs' outcomes and TypeScript output are unchanged, and some ledger keys change. Evidence: the conformance suite and the test run above.
Refs #83