feat(laurel): Add Seq<T> and Array<T> types with sequence/array operations#787
Closed
fabiomadge wants to merge 3 commits intostrata-org:mainfrom
Closed
feat(laurel): Add Seq<T> and Array<T> types with sequence/array operations#787fabiomadge wants to merge 3 commits intostrata-org:mainfrom
fabiomadge wants to merge 3 commits intostrata-org:mainfrom
Conversation
…tions Sequences (immutable value types): - TSeq variant in HighType; Seq<T> grammar syntax - [1, 2, 3] sequence literals (desugared to Sequence.build chains) - s[i] subscript read and s[i := v] functional update - 9 external Sequence.* functions (empty, build, select, update, length, append, contains, take, drop) - Seq<T> translates to Core's Sequence type; SMT verification works end-to-end Arrays (mutable heap-backed): - TArray variant in HighType; Array<T> grammar syntax - a[i] read and a[i] := v write with heap semantics - Aliasing: b := a; b[0] := 99; assert a[0] == 99 - Seq literal to Array conversion: var a: Array<int> := [1, 2, 3] - Synthetic Array composite with $data: Seq<int> field - Box wrapping for Seq-typed fields (BoxSeq/Box..SeqVal!) - Array<T> recognized as composite in modifies clauses Shared infrastructure: - Subscript AST node with SubscriptElim type-aware pass - SubscriptElim dispatches Seq subscripts to StaticCall, Array subscripts to FieldSelect + Sequence.* - Generic fix for 0-ary op formatting in Core VC output - Fix: AstNode.getType for .staticProcedure - Fix: targetTypeName for Applied/TArray types
Bug fixes: - highEq: add TSeq/TArray cases for type equality - collectTypeRefs: add TSeq/TArray for datatype SCC ordering - computeExprType: derive element type for Subscript nodes - elimProcedure: transform invokeOn expressions - subscriptElim: transform instance procedures in composites - classifyModifiesHighType: treat TArray as composite for modifies Code quality: - Centralize Sequence operation names in SeqOp namespace - Centralize Array composite name in arrayCompositeName - Clean up handleZeroaryOps with zeroAryBuiltinFunctions from Factory Test coverage: - T18_Sequences: append, contains, take, drop tests - T19_Arrays: loop with invariants, inter-procedural with modifies, Sequence.append on arrays
- Remove implicit Sequence.* coercion on Arrays (redirectArrayArgs) - Add Array.length as a declared function in CoreDefinitionsForLaurel - SubscriptElim rewrites Array.length(a) → Sequence.length(a.$data) - Add SeqOp.length constant, arrayLengthName constant - Update T19_Arrays tests to use Array.length, drop appendOnArrays
6365c90 to
74c59d4
Compare
|
👋 Hi, @fabiomadge, This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there. |
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.
Summary
Adds immutable sequences and mutable heap-backed arrays to Laurel with end-to-end SMT verification.
Sequences (immutable value types)
TSeqvariant inHighType;Seq<T>grammar syntax[1, 2, 3]sequence literals (desugared toSequence.buildchains)s[i]subscript read ands[i := v]functional updateSequence.*functions (empty, build, select, update, length, append, contains, take, drop)Seq<int>,Seq<bool>,Seq<Seq<int>>,Seq<Composite>Arrays (mutable heap-backed)
TArrayvariant inHighType;Array<T>grammar syntaxa[i]read anda[i] := vwrite with heap semanticsb := a; b[0] := 99; assert a[0] == 99var a: Array<int> := [1, 2, 3]Array<T>recognized as composite in modifies clausesArray<int>; other element types require heap model changesShared infrastructure
SubscriptAST node withSubscriptElimtype-aware pass (total, not partial)AstNode.getTypefor.staticProceduretargetTypeNameforTArraytypesKnown limitations
Array<bool>,Array<Seq<T>>,Array<Array<T>>don't work due to monomorphic Box/heap model