prevent panic with let alone in pipeline (#5676)

* prevent panic with `let` alone in pipeline

* Update parser.rs
This commit is contained in:
pwygab 2022-05-30 04:16:41 +08:00 committed by GitHub
parent c42096c34e
commit eb12fffbc6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4372,9 +4372,16 @@ pub fn parse_expression(
)
.0,
Some(ParseError::LetInPipeline(
String::from_utf8_lossy(working_set.get_span_contents(spans[spans.len() - 1]))
.to_string(),
String::from_utf8_lossy(working_set.get_span_contents(spans[1])).to_string(),
String::from_utf8_lossy(match spans.len() {
1 | 2 | 3 => b"value",
_ => working_set.get_span_contents(spans[3]),
})
.to_string(),
String::from_utf8_lossy(match spans.len() {
1 => b"variable",
_ => working_set.get_span_contents(spans[1]),
})
.to_string(),
spans[0],
)),
),