mirror of
https://github.com/nushell/nushell
synced 2025-01-27 20:35:43 +00:00
Fix bad operator (#3479)
This commit is contained in:
parent
3bcc2aad80
commit
5fcc7f2328
4 changed files with 23 additions and 4 deletions
|
@ -59,7 +59,11 @@ pub fn evaluate_baseline_expr(
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => Err(ShellError::labeled_error(
|
||||||
|
"Unknown operator",
|
||||||
|
"unknown operator",
|
||||||
|
binary.op.span,
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expression::Range(range) => {
|
Expression::Range(range) => {
|
||||||
|
|
|
@ -907,7 +907,10 @@ fn parse_arg(
|
||||||
}
|
}
|
||||||
|
|
||||||
SyntaxShape::Range => parse_range(&lite_arg, scope),
|
SyntaxShape::Range => parse_range(&lite_arg, scope),
|
||||||
SyntaxShape::Operator => parse_operator(&lite_arg),
|
SyntaxShape::Operator => (
|
||||||
|
garbage(lite_arg.span),
|
||||||
|
Some(ParseError::mismatch("operator", lite_arg.clone())),
|
||||||
|
),
|
||||||
SyntaxShape::Filesize => parse_filesize(&lite_arg),
|
SyntaxShape::Filesize => parse_filesize(&lite_arg),
|
||||||
SyntaxShape::Duration => parse_duration(&lite_arg),
|
SyntaxShape::Duration => parse_duration(&lite_arg),
|
||||||
SyntaxShape::FilePath => {
|
SyntaxShape::FilePath => {
|
||||||
|
@ -1230,7 +1233,7 @@ pub fn parse_math_expression(
|
||||||
prec.push(0);
|
prec.push(0);
|
||||||
|
|
||||||
while idx < lite_args.len() {
|
while idx < lite_args.len() {
|
||||||
let (op, err) = parse_arg(SyntaxShape::Operator, scope, &lite_args[idx]);
|
let (op, err) = parse_operator(&lite_args[idx]);
|
||||||
if error.is_none() {
|
if error.is_none() {
|
||||||
error = err;
|
error = err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ pub fn expression_to_flat_shape(e: &SpannedExpression) -> Vec<Spanned<FlatShape>
|
||||||
Expression::Binary(binary) => {
|
Expression::Binary(binary) => {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
output.append(&mut expression_to_flat_shape(&binary.left));
|
output.append(&mut expression_to_flat_shape(&binary.left));
|
||||||
output.push(FlatShape::Operator.spanned(binary.op.span));
|
output.append(&mut expression_to_flat_shape(&binary.op));
|
||||||
output.append(&mut expression_to_flat_shape(&binary.right));
|
output.append(&mut expression_to_flat_shape(&binary.right));
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
|
|
@ -433,6 +433,18 @@ fn can_process_one_row_from_internal_and_pipes_it_to_stdin_of_external() {
|
||||||
assert_eq!(actual.out, "nushell");
|
assert_eq!(actual.out, "nushell");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn bad_operator() {
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: ".",
|
||||||
|
r#"
|
||||||
|
2 $ 2
|
||||||
|
"#
|
||||||
|
);
|
||||||
|
|
||||||
|
assert!(actual.err.contains("operator"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn index_out_of_bounds() {
|
fn index_out_of_bounds() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
|
|
Loading…
Reference in a new issue