diff options
Diffstat (limited to 'src/wasm-validator.h')
-rw-r--r-- | src/wasm-validator.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/wasm-validator.h b/src/wasm-validator.h index 49e7a6a33..435fd1118 100644 --- a/src/wasm-validator.h +++ b/src/wasm-validator.h @@ -19,6 +19,26 @@ public: // visitors + void visitLoop(Loop *curr) override { + if (curr->in.is()) { + // the "in" label has a none type, since no one can receive its value. make sure no one breaks to it with a value. + struct ChildChecker : public WasmWalker { + Name in; + bool valid = true; + + ChildChecker(Name in) : in(in) {} + + void visitBreak(Break *curr) override { + if (curr->name == in && curr->value) { + valid = false; + } + } + }; + ChildChecker childChecker(curr->in); + childChecker.walk(curr->body); + shouldBeTrue(childChecker.valid); + } + } void visitSetLocal(SetLocal *curr) override { shouldBeTrue(curr->type == curr->value->type); } |