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
This commit is contained in:
132ikl 2025-02-11 04:35:23 -05:00 committed by GitHub
parent 781c4bd1d7
commit 553c951a60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,