From 5c7c256620c11c120f5db7feb9c77bdccd55ee3c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 27 Jul 2023 09:39:11 -0700 Subject: Fix a crash in TypeRefining on bottom types (#5842) Followup to #5840 --- src/passes/TypeRefining.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/passes/TypeRefining.cpp b/src/passes/TypeRefining.cpp index 9a0b289e5..211df8186 100644 --- a/src/passes/TypeRefining.cpp +++ b/src/passes/TypeRefining.cpp @@ -400,11 +400,16 @@ struct TypeRefining : public Pass { void visitStructSet(StructSet* curr) { if (curr->type == Type::unreachable) { + // Ignore unreachable code. + return; + } + auto type = curr->ref->type.getHeapType(); + if (type.isBottom()) { + // Ignore a bottom type. return; } - auto fieldType = - curr->ref->type.getHeapType().getStruct().fields[curr->index].type; + auto fieldType = type.getStruct().fields[curr->index].type; if (!Type::isSubType(curr->value->type, fieldType)) { curr->value = -- cgit v1.2.3