summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/wasm-builder.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/wasm-builder.h b/src/wasm-builder.h
index 8b34d6933..73803e37d 100644
--- a/src/wasm-builder.h
+++ b/src/wasm-builder.h
@@ -1295,7 +1295,12 @@ public:
return ExpressionManipulator::refNull(curr, curr->type);
}
if (curr->type.isRef() && curr->type.getHeapType() == HeapType::i31) {
- return makeI31New(makeConst(0));
+ Expression* ret = makeI31New(makeConst(0));
+ if (curr->type.isNullable()) {
+ // To keep the type identical, wrap it in a block that adds nullability.
+ ret = makeBlock({ret}, curr->type);
+ }
+ return ret;
}
if (!curr->type.isBasic()) {
// We can't do any better, keep the original.