mirror of
https://github.com/nushell/nushell.git
synced 2025-08-15 19:27:52 +02:00
add dedicated const in pipeline
, const builtin var
errors (#7784)
# Description Currently `let` and `const` share error handling, and this might lead to confusing error messages  This PR adds dedicated errors to `const`
This commit is contained in:
@ -5001,7 +5001,7 @@ pub fn parse_expression(
|
||||
.0,
|
||||
Some(ParseError::BuiltinCommandInPipeline("for".into(), spans[0])),
|
||||
),
|
||||
b"let" | b"const" => (
|
||||
b"let" => (
|
||||
parse_call(
|
||||
working_set,
|
||||
&spans[pos..],
|
||||
@ -5024,6 +5024,29 @@ pub fn parse_expression(
|
||||
spans[0],
|
||||
)),
|
||||
),
|
||||
b"const" => (
|
||||
parse_call(
|
||||
working_set,
|
||||
&spans[pos..],
|
||||
spans[0],
|
||||
expand_aliases_denylist,
|
||||
is_subexpression,
|
||||
)
|
||||
.0,
|
||||
Some(ParseError::ConstInPipeline(
|
||||
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],
|
||||
)),
|
||||
),
|
||||
b"mut" => (
|
||||
parse_call(
|
||||
working_set,
|
||||
|
Reference in New Issue
Block a user