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

Support reference types in spec #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

SPY
Copy link
Collaborator

@SPY SPY commented Dec 15, 2023

The PR is supposed to address issues #20 and #30 by replacing funcref and externref with more detailed {ref: HeapType, nullable: bool} dictionary.
WebAssembly.Function.type() will return {ref: 'any', nullable} for any GC type, but new WebAssembly.Function will throw an error if it will be called with a signature containing {ref: 'any', nullable} types.
This behaviour is supposed to be replaced with more detailed support in the future under cover of GC subgroup.

@eqrion
Copy link
Contributor

eqrion commented Dec 17, 2023

@SPY . So if I export a function like:

(type $s (struct ...))
(func (param (ref $s))

And call .type() on it, I will get:

{
  params: [{ref: 'any', nullable: false}]
}

Effectively taking the more precise type of ref $s and replacing it with ref any.

My understanding from the last in-person CG meeting is that this is not the behavior we want. This would mean that anyone reading .type to construct functions that are compatible with that function would create it with an incorrect type and get a link error.

We should instead throw an exception here.

@SPY
Copy link
Collaborator Author

SPY commented Dec 18, 2023

@eqrion I think I misunderstood in-person discussion, thanks for correction.
Throwing on "unsupported" types in type() is even easier and sounds right to me as well.
I will propose the change to the spec in the separate PR then.

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