Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elaborate on habitability of exact references #14

Merged
merged 1 commit into from
Mar 13, 2025
Merged

Conversation

tlively
Copy link
Member

@tlively tlively commented Mar 12, 2025

No description provided.

@tlively
Copy link
Member Author

tlively commented Mar 12, 2025

cc @sjrd and @rossberg

Copy link

@sjrd sjrd left a comment

Choose a reason for hiding this comment

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

That's very clear, thank you.

@tlively tlively merged commit 2a143d7 into main Mar 13, 2025
@rossberg
Copy link
Member

rossberg commented Mar 13, 2025

Why not make the others uninhabited as well? With exn in particular there could in fact be motivation to introduce subtypes in the future (e.g., ones that disclose the tag's type or something like that). With i31 you could theoretically have subtypes that record something about the value range (e.g., fits a byte etc), although that seems unlikely. But I'd suggest not to take any chances, especially since I see no particular benefit in using these — they don't add any precision today.

@jakobkummerow
Copy link
Contributor

Why not go yet another step further and disallow exact on abstract (i.e. non-indexed) references?

That would entirely rule out anyone relying on any specific behavior of exact abstract references, so it would have maximum forwards compatibility to any spec changes we might desire to make in the future.

For implementations consuming Wasm, enforcing this rule would be a pretty simple check in the decoder (even easier than enforcing that cont $x is only valid for $x being the index of a signature type); internal algorithms and data structures may bake in this restriction if they wish, and they are also free to assume that exact can apply to any ref type, even if the decoder won't actually let that happen. If an implementation makes this latter choice and also happens to produce Wasm, it'll need a comparably simple check in its backend: whenever it feels tempted to emit (ref exact <abstract>), it can just replace that with any other uninhabitable type, such as (ref none), or an unreachable instruction if this occurs in a code context.

(Taking a step back, I think as a general principle we should err on the side of disallowing things that have no use case, rather than allowing them "for consistency". Having to support nonsensical/unused things, in general, adds significant complexity. We can always relax such restrictions later (or lift them entirely) if use cases arise.)

@rossberg
Copy link
Member

@jakobkummerow, see the discussion on #9.

@jakobkummerow
Copy link
Contributor

@rossberg yes, what about it? Consensus in that discussion was that exact abstract types are both harmless and useless. I'm asking why we don't just drop them on account of their uselessness. That would certainly address the concerns in your previous post about exn and i31.

@rossberg
Copy link
Member

That also was the question we discussed there.

@tlively
Copy link
Member Author

tlively commented Mar 13, 2025

I support having a more in-depth discussion about whether we should allow exact references to abstract types at all. Thanks for opening #15, @jakobkummerow.

While that conversation is pending, I will update the overview to say that (ref exact {i31,exn,waitqueue}) are uninhabited as well. I still think we need to update ref.null to produce an exact reference so ref.null none produces (ref null exact none) and can be used in locations that expect a (ref null exact $Foo).

@tlively
Copy link
Member Author

tlively commented Mar 13, 2025

I opened #16 to make this change.

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.

4 participants