feat: Implement arrays of structs #1068
Merged
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.
Related issue(s)
Resolves #none
Description
Summary of changes
Implements arrays of structs by converting them into structs of arrays during monomorphization.
This PR has 1 issue / TODO that I will create a separate issue for and fix in a later PR if this is merged. It is that during the SOA conversion, some elements of the Ast are cloned naively without regard as to whether cloning them may cause side-effects to be re-evaluated. This issue should be rare as it should only occur if e.g. array elements contain a
constrain
or mutate values, which they would need to contain a BlockExpression for.Dependency additions / changes
Test additions / changes
Checklist
cargo fmt
with default settings.Documentation needs
We can remove the note in our documentation that one cannot define arrays of structs as it is now possible. Crucially however, we still cannot have arrays of arrays (nested arrays), or arrays of structs where the structs themselves contain arrays.
Additional context