From 553c951a60476e7ca22cdff5fa5ac4cb191e16b6 Mon Sep 17 00:00:00 2001 From: 132ikl <132@ikl.sh> Date: Tue, 11 Feb 2025 04:35:23 -0500 Subject: [PATCH] Fix match running closures as block (#15032) # Description This PR makes `match` no longer run closures as if they were blocks. This also allows returning closures from `match` without needing to wrap in an outer subexpression or block. Before PR: ```nushell match 1 { _ => {|| print hi} } # => hi ``` After PR: ```nushell match 1 { _ => {|| print hi} } # => closure_1090 ``` # User-Facing Changes * `match` no longer runs closures as if they were blocks # Tests + Formatting N/A # After Submitting N/A --- crates/nu-engine/src/compile/keyword.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nu-engine/src/compile/keyword.rs b/crates/nu-engine/src/compile/keyword.rs index b22e055a21..7d5b2abf29 100644 --- a/crates/nu-engine/src/compile/keyword.rs +++ b/crates/nu-engine/src/compile/keyword.rs @@ -255,7 +255,7 @@ pub(crate) fn compile_match( builder.drop_reg(match_reg)?; // Execute match right hand side expression - if let Some(block_id) = expr.as_block() { + if let Expr::Block(block_id) = expr.expr { let block = working_set.get_block(block_id); compile_block( working_set,