update param of BinaryenRefNull to take BinaryenHeapType - #8981
Open
chharvey wants to merge 3 commits into
Open
Conversation
chharvey
marked this pull request as draft
August 8, 2026 08:34
chharvey
marked this pull request as ready for review
August 8, 2026 14:00
chharvey
commented
Aug 8, 2026
| function initializeConstants() { | ||
|
|
||
| // Types | ||
| [ ['none', 'None'], |
Contributor
Author
There was a problem hiding this comment.
This 'none' (BinaryenTypeNone()) refers to the type with stack effect [t*] -> []. It is not the WASM heap type none (BinaryenHeapTypeNone()), nor the WASM ref type (ref null none) (BinaryenTypeNullref()).
We should probably document this somewhere or change it to a less conflicting name like 'void'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
According to the WASM spec, the
(ref.null <ht>)instruction takes a heap type as an argument, not a reference type. This PR updatesBinaryenRefNullto align with that.The parameter is changed from a
BinaryenTypeto aBinaryenHeapTypeand removes the nullable assertion. This puts the onus on the caller to make sure they are passing in a correct type.This is a breaking change and would require callers to be more careful about their arguments, but it provides for a more spec-aligned and predictable API.
Problem Statement
As an example of a problem it solves: say you’re using GC and you define your own custom heap type (example in JS):
and then you want to create a null-ref expression
(ref.null $NumberUnion)in your module code:To fix, you have to create your own nullable ref type first:
With this PR’s proposed change, you can now just call
BinaryenRefNullpassing in your heap type.