diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-05-20 11:21:47 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-05-20 11:21:47 -0700 |
commit | b28a3a6eba4c4fbe64333dd544977a0c4f37c650 (patch) | |
tree | 0919805194011cc453e7074030dc15c1342f67c3 /src/wasm-validator.h | |
parent | 244da920eedafec42da4e91b83c09d0021a36a7f (diff) | |
parent | a2f3fbdc80b72fcf04a789e723de7f5561387dcc (diff) | |
download | binaryen-b28a3a6eba4c4fbe64333dd544977a0c4f37c650.tar.gz binaryen-b28a3a6eba4c4fbe64333dd544977a0c4f37c650.tar.bz2 binaryen-b28a3a6eba4c4fbe64333dd544977a0c4f37c650.zip |
Merge pull request #531 from WebAssembly/fixes
Type checking fixes
Diffstat (limited to 'src/wasm-validator.h')
-rw-r--r-- | src/wasm-validator.h | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/src/wasm-validator.h b/src/wasm-validator.h index 8e94fd368..a19071959 100644 --- a/src/wasm-validator.h +++ b/src/wasm-validator.h @@ -56,9 +56,6 @@ public: } void visitLoop(Loop *curr) { if (curr->in.is()) { - LoopChildChecker childChecker(curr->in); - childChecker.walk(curr->body); - shouldBeTrue(childChecker.valid, curr, "loop must return none"); breakTypes.erase(curr->in); } if (curr->out.is()) { @@ -209,7 +206,13 @@ public: void visitReturn(Return* curr) { if (curr->value) { - returnType = curr->value->type; + if (returnType == unreachable) { + returnType = curr->value->type; + } else if (curr->value->type != unreachable && returnType != curr->value->type) { + returnType = none; // poison + } + } else { + returnType = none; } } @@ -285,20 +288,6 @@ public: private: - // 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 LoopChildChecker : public PostWalker<LoopChildChecker, Visitor<LoopChildChecker>> { - Name in; - bool valid = true; - - LoopChildChecker(Name in) : in(in) {} - - void visitBreak(Break *curr) { - if (curr->name == in && curr->value) { - valid = false; - } - } - }; - // helpers std::ostream& fail() { |