summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-03-21 19:08:49 -0700
committerGitHub <noreply@github.com>2024-03-21 19:08:49 -0700
commitf5147a14e7a7c447bfbc38d05dff19a5231697c0 (patch)
treed82ff60f96a446065aced40c2fc1c32b0c31f5eb
parentccfd01e960fad738f0a3151970b7124dcd2b9e32 (diff)
downloadbinaryen-f5147a14e7a7c447bfbc38d05dff19a5231697c0.tar.gz
binaryen-f5147a14e7a7c447bfbc38d05dff19a5231697c0.tar.bz2
binaryen-f5147a14e7a7c447bfbc38d05dff19a5231697c0.zip
Mark non-closed types as requiring GC (#6421)
This omission was able to cause a problem with text round-tripping.
-rw-r--r--src/wasm/wasm-type.cpp2
-rw-r--r--test/lit/validation/open-types-no-gc.wast13
2 files changed, 14 insertions, 1 deletions
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp
index b14e5aa39..5957f9388 100644
--- a/src/wasm/wasm-type.cpp
+++ b/src/wasm/wasm-type.cpp
@@ -933,7 +933,7 @@ FeatureSet Type::getFeatures() const {
if (heapType->isStruct() || heapType->isArray() ||
heapType->getRecGroup().size() > 1 ||
- heapType->getDeclaredSuperType()) {
+ heapType->getDeclaredSuperType() || heapType->isOpen()) {
feats |= FeatureSet::ReferenceTypes | FeatureSet::GC;
} else if (heapType->isSignature()) {
// This is a function reference, which requires reference types and
diff --git a/test/lit/validation/open-types-no-gc.wast b/test/lit/validation/open-types-no-gc.wast
new file mode 100644
index 000000000..189d4e464
--- /dev/null
+++ b/test/lit/validation/open-types-no-gc.wast
@@ -0,0 +1,13 @@
+;; Test that declaring non-final types without GC is a validation error.
+
+;; RUN: not wasm-opt %s -all --disable-gc 2>&1 | filecheck %s
+
+;; CHECK: all used types should be allowed
+
+(module
+ (type $f1 (sub (func)))
+
+ (func $test (type $f1)
+ (unreachable)
+ )
+) \ No newline at end of file