diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 0c78442a7ee..e9adc5e0ed0 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -2037,7 +2037,11 @@ Type WasmBinaryReader::getType(int initial) { // Single value types are negative; signature indices are non-negative if (initial >= 0) { // TODO: Handle block input types properly. - return getSignatureByTypeIndex(initial).results; + auto sig = getSignatureByTypeIndex(initial); + if (sig.params != Type::none) { + throwError("control flow inputs are not supported yet"); + } + return sig.results; } Type type; if (getBasicType(initial, type)) { @@ -2088,7 +2092,7 @@ HeapType WasmBinaryReader::getIndexedHeapType() { Type WasmBinaryReader::getConcreteType() { auto type = getType(); if (!type.isConcrete()) { - throw ParseException("non-concrete type when one expected"); + throwError("non-concrete type when one expected"); } return type; } diff --git a/test/lit/binary/bad-multivalue-block.test b/test/lit/binary/bad-multivalue-block.test new file mode 100644 index 00000000000..8b100fe89ed --- /dev/null +++ b/test/lit/binary/bad-multivalue-block.test @@ -0,0 +1,16 @@ +;; Test that we error properly on a block with a bad multivalue (inputs). + +;; File contents: +;; +;; (module +;; (func $test +;; i32.const 0 +;; (block (param i32) +;; drop +;; ) +;; ) +;; ) + +;; RUN: not wasm-opt -all %s.wasm 2>&1 | filecheck %s + +;; CHECK: control flow inputs are not supported yet diff --git a/test/lit/binary/bad-multivalue-block.test.wasm b/test/lit/binary/bad-multivalue-block.test.wasm new file mode 100644 index 00000000000..e44b9033f20 Binary files /dev/null and b/test/lit/binary/bad-multivalue-block.test.wasm differ diff --git a/test/lit/binary/bad-multivalue-if.test b/test/lit/binary/bad-multivalue-if.test new file mode 100644 index 00000000000..8fe20601285 --- /dev/null +++ b/test/lit/binary/bad-multivalue-if.test @@ -0,0 +1,22 @@ +;; Test that we error properly on an if with a bad multivalue (inputs). + +;; File contents: +;; +;; (module +;; (func $test +;; i32.const 0 +;; i32.const 1 +;; (if (param i32) +;; (then +;; drop +;; ) +;; (else +;; drop +;; ) +;; ) +;; ) +;; ) + +;; RUN: not wasm-opt -all %s.wasm 2>&1 | filecheck %s + +;; CHECK: control flow inputs are not supported yet diff --git a/test/lit/binary/bad-multivalue-if.test.wasm b/test/lit/binary/bad-multivalue-if.test.wasm new file mode 100644 index 00000000000..baddfec4ed7 Binary files /dev/null and b/test/lit/binary/bad-multivalue-if.test.wasm differ