wip
diff --git a/src/ir/subtype-exprs.h b/src/ir/subtype-exprs.h index eca3dac..c6a054a 100644 --- a/src/ir/subtype-exprs.h +++ b/src/ir/subtype-exprs.h
@@ -599,9 +599,11 @@ self()->noteSubtype(currResult, retSig.results); } void visitStructWait(StructWait* curr) { - if (curr->ref->type.isRef()) { - self()->noteSubtype(curr->ref->type.getHeapType(), curr->structType); + if (!curr->ref->type.isRef()) { + return; } + + self()->noteSubtype(curr->ref->type.getHeapType(), curr->structType); } };
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 8ac0d3c..fb4a631 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp
@@ -4268,15 +4268,6 @@ curr, "struct.wait requires shared-everything [--enable-shared-everything]"); - // if (curr->ref->type == Type::unreachable) { - // return; - // } - - // auto validateWaitQueueArg = [&]() { - // if (curr->ref->type == Type::unreachable) - // } - // validateWaitQueueArg(); - shouldBeSubType( curr->ref->type, Type(curr->structType, Nullable), @@ -4300,6 +4291,7 @@ return; } + // In practice this likely fails during parsing instead. shouldBeTrue(curr->index < curr->structType.getStruct().fields.size(), curr, "struct.wait index immediate should be less than the field "
diff --git a/test/spec/waitqueue.wast b/test/spec/waitqueue.wast index 3a2ac4f..ac85d5e 100644 --- a/test/spec/waitqueue.wast +++ b/test/spec/waitqueue.wast
@@ -1,6 +1,6 @@ (assert_invalid (module - (type $t (struct (field i32))) + (type $t (struct (field i32) (field waitqueue))) (func (param $expected i32) (param $timeout i64) (result i32) (struct.wait $t 0 (ref.null $t) (local.get $expected) (local.get $timeout)) ) @@ -9,6 +9,15 @@ (assert_invalid (module + (type $t (struct (field i32) (field waitqueue))) + (func (param $expected i32) (param $timeout i64) (result i32) + (struct.wait $t 2 (ref.null $t) (local.get $expected) (local.get $timeout)) + ) + ) "struct index out of bounds" +) + +(assert_invalid + (module (type $t (struct (field waitqueue))) (global $g (ref $t) (struct.new $t (i32.const 0))) (func (param $expected i32) (param $timeout i64) (result i32) @@ -27,7 +36,7 @@ ) "struct.wait timeout must be an i64" ) -;; passes validation +;; unreachable is allowed (module (type $t (struct (field i32))) (func (param $expected i32) (param $timeout i64) (result i32) @@ -35,7 +44,6 @@ ) ) - (module (type $t (struct (field waitqueue)))