summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-01-11 21:14:49 +0000
committerGitHub <noreply@github.com>2021-01-11 13:14:49 -0800
commite8e97f3dec5098bbadcfa0814b3a4f4081474b75 (patch)
treed90555c0062d7bbf75d9c4eede6d359e64404d4c /src/wasm/wasm-validator.cpp
parenteadb53c442209962f98dde22f3b769c691398cad (diff)
downloadbinaryen-e8e97f3dec5098bbadcfa0814b3a4f4081474b75.tar.gz
binaryen-e8e97f3dec5098bbadcfa0814b3a4f4081474b75.tar.bz2
binaryen-e8e97f3dec5098bbadcfa0814b3a4f4081474b75.zip
[GC] Add Type::IsDefaultable and use that to do more validation (#3456)
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index bf6e121bf..b0fc4d9c8 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -2294,8 +2294,7 @@ void FunctionValidator::visitStructNew(StructNew* curr) {
"struct.new_with_default should have no operands");
// All the fields must be defaultable.
for (const auto& field : fields) {
- // TODO: add type.isDefaultable()?
- shouldBeTrue(!field.type.isRef() || field.type.isNullable(),
+ shouldBeTrue(field.type.isDefaultable(),
field,
"struct.new_with_default value type must be defaultable");
}
@@ -2368,8 +2367,7 @@ void FunctionValidator::visitArrayNew(ArrayNew* curr) {
shouldBeTrue(
!curr->init, curr, "array.new_with_default should have no init");
// The element must be defaultable.
- // TODO: add type.isDefaultable()?
- shouldBeTrue(!element.type.isRef() || element.type.isNullable(),
+ shouldBeTrue(element.type.isDefaultable(),
element,
"array.new_with_default value type must be defaultable");
} else {
@@ -2439,8 +2437,7 @@ void FunctionValidator::visitFunction(Function* curr) {
}
for (const auto& var : curr->vars) {
features |= var.getFeatures();
- shouldBeTrue(var.isConcrete(), curr, "vars must be concretely typed");
- // TODO: check for nullability
+ shouldBeTrue(var.isDefaultable(), curr, "vars must be defaultable");
}
shouldBeTrue(features <= getModule()->features,
curr->name,