Skip to content

Fix propagation bug in Unsubtyping#8468

Merged
tlively merged 2 commits intomainfrom
unsubtyping-fix-propagation
Mar 16, 2026
Merged

Fix propagation bug in Unsubtyping#8468
tlively merged 2 commits intomainfrom
unsubtyping-fix-propagation

Conversation

@tlively
Copy link
Member

@tlively tlively commented Mar 14, 2026

Unsubtyping has to propagate a subtypesExposedToJS marker from supertypes to subtypes. It previously did this by propagating from supertype to subtype whenever a new subtyping relationship was found. But subtyping trees are not always built from top to bottom. In cases where the newly discovered subtype already had subtypes, the previous propagation scheme would fail to propagate to those transitive subtypes.

Fix the problem by propagating to the full subtype tree rooted at a newly discovered subtype. Use a DFS over the tree and avoid traversing subtrees that have already been marked to avoid introducing possible quadratic behavior.

Unsubtyping has to propagate a `subtypesExposedToJS` marker from supertypes to subtypes. It previously did this by propagating from supertype to subtype whenever a new subtyping relationship was found. But subtyping trees are not always built from top to bottom. In cases where the newly discovered subtype already had subtypes, the previous propagation scheme would fail to propagate to those transitive subtypes.

Fix the problem by propagating to the full subtype tree rooted at a newly discovered subtype. Use a DFS over the tree and avoid traversing subtrees that have already been marked to avoid introducing possible quadratic behavior.
@tlively tlively requested a review from kripken March 14, 2026 03:17
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
(@binaryen.js.called)
(func $expose-structref (result anyref)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
(func $expose-structref (result anyref)
(func $expose-anyref (result anyref)

@tlively tlively merged commit 2602030 into main Mar 16, 2026
17 checks passed
@tlively tlively deleted the unsubtyping-fix-propagation branch March 16, 2026 17:22
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