rework fusion framework based on immutable named types#6790
Merged
Conversation
nwt
reviewed
Apr 3, 2026
43063cd to
eef3593
Compare
Collaborator
Author
|
Now that we have named types fusing correctly and retained in the fusion type, I'm hitting a little problem where named type redefs cause a problem. Since we are getting rid of this with the forthcoming recursive types, I will work on a separate PR to disallow redefs of named types then rebase this work to that and continue on. It's getting close. |
Collaborator
Author
|
The immutable-types PR creates a new set of problems with the used of serialized super data in the database metadata. This will be solved with abstract types so deferring that and instead, here, we are going to just change fuser to error on mutated named types and avoid that case in the tests. |
05a9c70 to
e7f7deb
Compare
This commit reworks downcast, upcast, and fuser to presume that named types are immutable. The changes for immutability are forthcoming but the fusion code now assumes this invariant. This new design involves fused types carrying the named types instead of stripping them and deferring them to the fusion subtypes. This is key to allow the fusion runtime to manipulate named types. When support for recursive types is added, the recursive type will remain in the fusion and the concrete types will be fused below. With this approach, a fused recursive type will rarely need to be unfused. This commit also tightens up the algorithms for upcast/downcast so they should now be generally more reliable and can serve as a model for implementing their vam counterparts.
e7f7deb to
04e9f35
Compare
nwt
approved these changes
Apr 9, 2026
runtime/sam/expr/agg/fuser.go
Outdated
| if b, ok := b.(*super.TypeNamed); ok && a.Name == b.Name { | ||
| if a.Type != b.Type { | ||
| // The fusion algorithm does not handle named types that change. | ||
| // We will soon maked such types immutable, but for now we just |
Member
There was a problem hiding this comment.
Suggested change
| // We will soon maked such types immutable, but for now we just | |
| // We will soon make such types immutable, but for now we just |
runtime/sam/expr/function/upcast.go
Outdated
Comment on lines
+208
to
+211
| if t, ok := t.(*super.TypeNamed); ok && named.Name == t.Name { | ||
| return true | ||
| } | ||
| return false |
Member
There was a problem hiding this comment.
Suggested change
| if t, ok := t.(*super.TypeNamed); ok && named.Name == t.Name { | |
| return true | |
| } | |
| return false | |
| t, ok := t.(*super.TypeNamed) | |
| return ok && named.Name == t.Name |
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.
This commit reworks downcast, upcast, and fuser to presume
that named types are immutable. The changes for immutability
are forthcoming but the fusion code now assumes this invariant.
This new design involves fused types carrying the named types
instead of stripping them and deferring them to the fusion
subtypes. This is key to allow the fusion runtime to manipulate
named types. When support for recursive types is added,
the recursive type will remain in the fusion and the concrete types
will be fused below. With this approach, a fused recursive type will
rarely need to be unfused.
This commit also tightens up the algorithms for upcast/downcast
so they should now be generally more reliable and can serve as
a model for implementing their vam counterparts.