diff options
-rw-r--r-- | src/parser/parse-2-typedefs.cpp | 2 | ||||
-rw-r--r-- | test/lit/parse-bad-supertype-8616.wast | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/parser/parse-2-typedefs.cpp b/src/parser/parse-2-typedefs.cpp index 90a84941d..97ba247bd 100644 --- a/src/parser/parse-2-typedefs.cpp +++ b/src/parser/parse-2-typedefs.cpp @@ -34,7 +34,7 @@ Result<> parseTypeDefs( if (auto* err = built.getError()) { std::stringstream msg; msg << "invalid type: " << err->reason; - return ctx.in.err(decls.typeDefs[err->index].pos, msg.str()); + return ctx.in.err(decls.subtypeDefs[err->index].pos, msg.str()); } types = *built; // Record type names on the module and in typeNames. diff --git a/test/lit/parse-bad-supertype-8616.wast b/test/lit/parse-bad-supertype-8616.wast new file mode 100644 index 000000000..c7c3dc957 --- /dev/null +++ b/test/lit/parse-bad-supertype-8616.wast @@ -0,0 +1,11 @@ +;; RUN: not wasm-opt %s 2>&1 | filecheck %s + +;; CHECK: Fatal: 9:2: error: invalid type: Heap type has an undeclared supertype + +;; Regression test for a parser bug that caused an assertion failure in this case. +(module + (rec + (type $A (sub (struct (field i32)))) + (type $B (sub $B (struct (field i32) (field i32)))) + ) +)
\ No newline at end of file |