mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 00:13:21 +01:00
Fix bad operator (#3479)
This commit is contained in:
parent
3bcc2aad80
commit
5fcc7f2328
@ -59,7 +59,11 @@ pub fn evaluate_baseline_expr(
|
||||
)),
|
||||
}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
_ => Err(ShellError::labeled_error(
|
||||
"Unknown operator",
|
||||
"unknown operator",
|
||||
binary.op.span,
|
||||
)),
|
||||
}
|
||||
}
|
||||
Expression::Range(range) => {
|
||||
|
@ -907,7 +907,10 @@ fn parse_arg(
|
||||
}
|
||||
|
||||
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::Duration => parse_duration(&lite_arg),
|
||||
SyntaxShape::FilePath => {
|
||||
@ -1230,7 +1233,7 @@ pub fn parse_math_expression(
|
||||
prec.push(0);
|
||||
|
||||
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() {
|
||||
error = err;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ pub fn expression_to_flat_shape(e: &SpannedExpression) -> Vec<Spanned<FlatShape>
|
||||
Expression::Binary(binary) => {
|
||||
let mut output = vec![];
|
||||
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
|
||||
}
|
||||
|
@ -433,6 +433,18 @@ fn can_process_one_row_from_internal_and_pipes_it_to_stdin_of_external() {
|
||||
assert_eq!(actual.out, "nushell");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bad_operator() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
2 $ 2
|
||||
"#
|
||||
);
|
||||
|
||||
assert!(actual.err.contains("operator"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn index_out_of_bounds() {
|
||||
let actual = nu!(
|
||||
|
Loading…
Reference in New Issue
Block a user