Skip to content

Comments

Handle indirectly JS-exposed types in Unsubtyping#8353

Merged
tlively merged 3 commits intomainfrom
unsubtyping-jsinterop-supertypes
Feb 20, 2026
Merged

Handle indirectly JS-exposed types in Unsubtyping#8353
tlively merged 3 commits intomainfrom
unsubtyping-jsinterop-supertypes

Conversation

@tlively
Copy link
Member

@tlively tlively commented Feb 20, 2026

We previously updated Unsubtyping to preserve prototype-configuring
descriptors on types that are exposed to JS via JS-called functions, but
we didn't handle the case where a supertype without a descriptor is
exposed to JS, potentially exposing configured prototypes on its
subtypes that do have descriptors. Fix this and also newly handle types
exposed to JS via extern.convert_any.

We previously updated Unsubtyping to preserve prototype-configuring
descriptors on types that are exposed to JS via JS-called functions, but
we didn't handle the case where a supertype without a descriptor is
exposed to JS, potentially exposing configured prototypes on its
subtypes that do have descriptors. Fix this and also newly handle types
exposed to JS via extern.convert_any.
@tlively tlively requested a review from kripken February 20, 2026 16:35
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

lgtm % questions

}
void visitRefAs(RefAs* curr) {
Super::visitRefAs(curr);
if (curr->op == ExternConvertAny && curr->value->type.isRef()) {
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment here.

)

;; Since we assume with a closed world that the environment does not do
;; anything to observe differences bewteen private subtypes and their public
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
;; anything to observe differences bewteen private subtypes and their public
;; anything to observe differences between private subtypes and their public


;; CHECK: (global $private (ref null $private-sub) (ref.null none))
(global $private (ref null $private-sub) (ref.null none))
)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not quite sure I see how this last testcase relates to JS interop?

Copy link
Member Author

Choose a reason for hiding this comment

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

We might have reasonably chosen to consider public types JS-exposed by default, in which case we would have had to keep the descriptor in this test case. But I decided not to do that for now. This test case documents that policy decision.

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks. Perhaps add a note on that to the closed world comment in pass.h? Or maybe there's a better place.

Copy link
Member Author

Choose a reason for hiding this comment

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

I expanded the comment on the test. PTAL!

Copy link
Member

Choose a reason for hiding this comment

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

lgtm, but I still this we should document this in a more broad place like pass.h's closed-world docs? That can be separate from this PR if you want.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is already clear from the existing pass.h comment that "The outside may hold on to references and pass them back in, but may not inspect their contents, call them, or reflect on their types in any way." If we decided to change the behavior here, then it would make sense to update that comment to add a carve-out for reading configured prototypes.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, fair enough.

@tlively tlively requested a review from kripken February 20, 2026 18:40

;; CHECK: (global $private (ref null $private-sub) (ref.null none))
(global $private (ref null $private-sub) (ref.null none))
)
Copy link
Member

Choose a reason for hiding this comment

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

lgtm, but I still this we should document this in a more broad place like pass.h's closed-world docs? That can be separate from this PR if you want.

@tlively tlively merged commit 4efcdfe into main Feb 20, 2026
17 checks passed
@tlively tlively deleted the unsubtyping-jsinterop-supertypes branch February 20, 2026 18:48
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