Skip to content

Conversation

@rtfeldman
Copy link
Contributor

Summary

When a nominal type wraps an enum-like tag union (one with no payloads), the layout computation would incorrectly skip the nominal update, causing crashes with "cast causes pointer to be null" or "integer overflow" errors.

  • Added check for pending container before skipping nominal update in layout computation
  • The fix ensures enum-like tag unions (which resolve directly to scalars without creating pending containers) properly update the nominal's placeholder layout
  • Added regression tests for issue Panics #9011

Fixes #9011

Co-authored by Claude Opus 4.5

When a nominal type wraps an enum-like tag union (one with no payloads),
the layout computation would incorrectly skip the nominal update because
it checked for `.tag_union` structure type but didn't verify whether a
pending container actually existed.

Enum-like tag unions resolve directly to scalar layouts (the discriminant)
without creating a pending container. The existing code assumed all tag
unions would have pending containers, causing the nominal's placeholder
layout (Box(opaque_ptr)) to never be updated to the actual scalar layout.

This resulted in tuple elements getting Box layouts when they should have
had scalar layouts, causing crashes when the interpreter tried to incref
a discriminant value as if it were a pointer.

The fix checks if there's actually a pending container for the current
var before skipping the nominal update. If no pending container exists
(as is the case for enum-like tag unions), the update proceeds normally.

Fixes #9011

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.

Panics

2 participants