Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/wasm/wasm-binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
}
Expand Down
16 changes: 16 additions & 0 deletions test/lit/binary/bad-multivalue-block.test
Original file line number Diff line number Diff line change
@@ -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
Binary file added test/lit/binary/bad-multivalue-block.test.wasm
Binary file not shown.
22 changes: 22 additions & 0 deletions test/lit/binary/bad-multivalue-if.test
Original file line number Diff line number Diff line change
@@ -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
Binary file added test/lit/binary/bad-multivalue-if.test.wasm
Binary file not shown.