From fc4cea9f75074495a7194c41287184ace4106237 Mon Sep 17 00:00:00 2001 From: Folkert Date: Mon, 3 Jan 2022 16:50:43 +0100 Subject: [PATCH] don't throw away a jump --- compiler/mono/src/ir.rs | 7 ++++++- examples/benchmarks/Issue2279.roc | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index 8356aef776..3a5c368d04 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -2909,8 +2909,13 @@ fn specialize_naked_symbol<'a>( std::vec::Vec::new(), layout_cache, assigned, - env.arena.alloc(Stmt::Ret(assigned)), + env.arena.alloc(match hole { + Stmt::Jump(id, _) => Stmt::Jump(*id, env.arena.alloc([assigned])), + Stmt::Ret(_) => Stmt::Ret(assigned), + _ => unreachable!(), + }), ); + return result; } } diff --git a/examples/benchmarks/Issue2279.roc b/examples/benchmarks/Issue2279.roc index 2adffc6c8b..0b85cdd904 100644 --- a/examples/benchmarks/Issue2279.roc +++ b/examples/benchmarks/Issue2279.roc @@ -4,8 +4,10 @@ app "issue2279" provides [ main ] to pf main = - t1 = Issue2279Help.asText 42 - t2 = Issue2279Help.text - text = if True then t1 else t2 + text = + if True then + Issue2279Help.text + else + Issue2279Help.asText 42 Task.putLine text