summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm/literal.cpp5
-rw-r--r--test/spec/convert_extern.wast8
2 files changed, 11 insertions, 2 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp
index afbee4435..7e4aeb8c7 100644
--- a/src/wasm/literal.cpp
+++ b/src/wasm/literal.cpp
@@ -2687,11 +2687,12 @@ Literal Literal::relaxedFmsF64x2(const Literal& left,
Literal Literal::externalize() const {
assert(type.isRef() && type.getHeapType().getUnsharedTop() == HeapType::any &&
"can only externalize internal references");
+ auto share = type.getHeapType().getShared();
if (isNull()) {
- return Literal(std::shared_ptr<GCData>{}, HeapType::noext);
+ return Literal(std::shared_ptr<GCData>{}, HeapTypes::noext.getBasic(share));
}
auto heapType = type.getHeapType();
- auto extType = HeapTypes::ext.getBasic(heapType.getShared());
+ auto extType = HeapTypes::ext.getBasic(share);
if (heapType.isMaybeShared(HeapType::i31)) {
return Literal(std::make_shared<GCData>(heapType, Literals{*this}),
extType);
diff --git a/test/spec/convert_extern.wast b/test/spec/convert_extern.wast
index 36254bc4a..443bc8956 100644
--- a/test/spec/convert_extern.wast
+++ b/test/spec/convert_extern.wast
@@ -5,7 +5,15 @@
(ref.null (shared noextern))
)
)
+
+ (func $shared-null-rev (export "shared-null-rev") (result (ref null (shared extern)))
+ ;; As before, but the reverse conversion.
+ (extern.convert_any
+ (ref.null (shared any))
+ )
+ )
)
(assert_return (invoke "shared-null") (ref.null (shared any)))
+(assert_return (invoke "shared-null-rev") (ref.null (shared extern)))