mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
handle empty pipeline while parsing let (fix Issue10083) (#10116)
- fixes #10083 # Description nushell crashes in the following 2 condition: - `let a = {}` , then delete `{` - `let a = | {}`, then delete `{` When delete `{` the pipeline becomes empty but current `nu-parser` assume they are non-empty. This pr adds extra empty check to avoid crash. Co-authored-by: Horasal <horsal@horsal.dev>
This commit is contained in:
@ -1007,6 +1007,18 @@ mod string {
|
||||
}
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case(b"let a = }")]
|
||||
#[case(b"mut a = }")]
|
||||
#[case(b"let a = | }")]
|
||||
#[case(b"mut a = | }")]
|
||||
fn test_semi_open_brace(#[case] phrase: &[u8]) {
|
||||
let engine_state = EngineState::new();
|
||||
let mut working_set = StateWorkingSet::new(&engine_state);
|
||||
// this should not panic
|
||||
let _block = parse(&mut working_set, None, phrase, true);
|
||||
}
|
||||
|
||||
mod range {
|
||||
use super::*;
|
||||
use nu_protocol::ast::{RangeInclusion, RangeOperator};
|
||||
|
Reference in New Issue
Block a user