From 92fb944ea31849a9ebe2fe02582335d439bec595 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 21 Apr 2026 07:49:43 -0700 Subject: [PATCH] fix --- src/wasm/wasm-ir-builder.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/wasm/wasm-ir-builder.cpp b/src/wasm/wasm-ir-builder.cpp index 6552df7e1a2..903e8e87167 100644 --- a/src/wasm/wasm-ir-builder.cpp +++ b/src/wasm/wasm-ir-builder.cpp @@ -2093,6 +2093,15 @@ Result<> IRBuilder::makeBrOn(Index label, } CHECK_ERR(visitBrOn(&curr)); + // Validate things that would cause errors later. + if (curr.ref->type != Type::unreachable && !curr.ref->type.isRef()) { + return Err{"br_on* ref must be a ref"}; + } + if (curr.desc && curr.desc->type != Type::unreachable && + !curr.desc->type.isRef()) { + return Err{"br_on_cast_desc* must be a ref"}; + } + // Validate type immediates before we forget them. switch (op) { case BrOnNull: