Skip to content

rework fusion framework based on immutable named types#6790

Merged
mccanne merged 2 commits intomainfrom
downcast-rework-fusion
Apr 9, 2026
Merged

rework fusion framework based on immutable named types#6790
mccanne merged 2 commits intomainfrom
downcast-rework-fusion

Conversation

@mccanne
Copy link
Copy Markdown
Collaborator

@mccanne mccanne commented Apr 3, 2026

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.

@mccanne mccanne force-pushed the downcast-rework-fusion branch 6 times, most recently from 43063cd to eef3593 Compare April 8, 2026 17:12
@mccanne
Copy link
Copy Markdown
Collaborator Author

mccanne commented Apr 8, 2026

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.

@mccanne
Copy link
Copy Markdown
Collaborator Author

mccanne commented Apr 9, 2026

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.

@mccanne mccanne force-pushed the downcast-rework-fusion branch from 05a9c70 to e7f7deb Compare April 9, 2026 15:55
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.
@mccanne mccanne force-pushed the downcast-rework-fusion branch from e7f7deb to 04e9f35 Compare April 9, 2026 15:57
@mccanne mccanne changed the title [downcast-rework-fusion] rework fusion framework based on immutable named types Apr 9, 2026
@mccanne mccanne marked this pull request as ready for review April 9, 2026 16:00
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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +208 to +211
if t, ok := t.(*super.TypeNamed); ok && named.Name == t.Name {
return true
}
return false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@mccanne mccanne merged commit 5602890 into main Apr 9, 2026
2 checks passed
@mccanne mccanne deleted the downcast-rework-fusion branch April 9, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants