prevent panic when parsing incomplete multi-expr (|) matches (#15230)

Fixes #14971, fixes #15229

# User-Facing Changes

Fixes a panic when variable data is accessed after invalid usage of the
`|` separator, which made it impossible to type certain match arms:

```nushell
> match $in { 1 |
Error:   x Main thread panicked.
  |-> at crates/nu-protocol/src/engine/state_delta.rs💯14
  `-> internal error: missing required scope frame
```

# Description

Removes duplicative calls to `exit_scope` from an inner loop when `|`
parse errors are encountered. The outer loop creates and exits scopes
for each match arm.
This commit is contained in:
Solomon
2025-03-04 11:34:34 +00:00
committed by GitHub
parent de7b000505
commit 4779d69de6
2 changed files with 7 additions and 4 deletions

View File

@ -4680,8 +4680,6 @@ pub fn parse_match_block_expression(working_set: &mut StateWorkingSet, span: Spa
"end of input".into(),
Span::new(output[position - 1].span.end, output[position - 1].span.end),
));
working_set.exit_scope();
break;
}
@ -4695,8 +4693,6 @@ pub fn parse_match_block_expression(working_set: &mut StateWorkingSet, span: Spa
"end of input".into(),
Span::new(output[position - 1].span.end, output[position - 1].span.end),
));
working_set.exit_scope();
break;
} else {
connector = working_set.get_span_contents(output[position].span);