From f8ab025a9e5c6ec0039849dffbe3fef5d79d928e Mon Sep 17 00:00:00 2001 From: Ary Borenszweig Date: Wed, 22 Jan 2025 18:07:20 -0300 Subject: [PATCH] Check that runtimes match --- .../noirc_evaluator/src/ssa/opt/inlining.rs | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/compiler/noirc_evaluator/src/ssa/opt/inlining.rs b/compiler/noirc_evaluator/src/ssa/opt/inlining.rs index 158a8193dce..5ff9622353e 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/inlining.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/inlining.rs @@ -892,19 +892,17 @@ impl<'function> PerFunctionContext<'function> { } let callee = &ssa.functions[&called_func_id]; + let callee_runtime = callee.runtime(); - match callee.runtime() { - RuntimeType::Acir(inline_type) => { - // If the called function is acir, we inline if it's not an entry point - if inline_type.is_entry_point() { - return None; - } - } - RuntimeType::Brillig(_) => { - if self.entry_function.runtime().is_acir() { - // We never inline a brillig function into an ACIR function. - return None; - } + // Wd never inline one runtime into another + if self.entry_function.runtime().is_acir() != callee_runtime.is_acir() { + return None; + } + + if let RuntimeType::Acir(inline_type) = callee_runtime { + // If the called function is acir, we inline if it's not an entry point + if inline_type.is_entry_point() { + return None; } }