summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm/literal.cpp5
-rw-r--r--test/spec/convert_extern.wast11
2 files changed, 14 insertions, 2 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp
index b3128025e..afbee4435 100644
--- a/src/wasm/literal.cpp
+++ b/src/wasm/literal.cpp
@@ -2700,11 +2700,12 @@ Literal Literal::externalize() const {
}
Literal Literal::internalize() const {
- auto extType = HeapTypes::ext.getBasic(type.getHeapType().getShared());
+ auto share = type.getHeapType().getShared();
+ auto extType = HeapTypes::ext.getBasic(share);
assert(Type::isSubType(type, Type(extType, Nullable)) &&
"can only internalize external references");
if (isNull()) {
- return Literal(std::shared_ptr<GCData>{}, HeapType::none);
+ return Literal(std::shared_ptr<GCData>{}, HeapTypes::none.getBasic(share));
}
if (gcData->type.isMaybeShared(HeapType::i31)) {
assert(gcData->values[0].type.getHeapType().isMaybeShared(HeapType::i31));
diff --git a/test/spec/convert_extern.wast b/test/spec/convert_extern.wast
new file mode 100644
index 000000000..36254bc4a
--- /dev/null
+++ b/test/spec/convert_extern.wast
@@ -0,0 +1,11 @@
+(module
+ (func $shared-null (export "shared-null") (result (ref null (shared any)))
+ ;; The shared null here should remain shared as we internalize it.
+ (any.convert_extern
+ (ref.null (shared noextern))
+ )
+ )
+)
+
+(assert_return (invoke "shared-null") (ref.null (shared any)))
+