make better error message for not operator (#10507)

Fixes: #10476

After the change, the error message will be something like this:
```nushell
❯ not null
Error: nu:🐚:type_mismatch

  × Type mismatch.
   ╭─[entry #11:1:1]
 1 │ not null
   ·     ──┬─
   ·       ╰── expected bool, found nothing
   ╰────
```
This commit is contained in:
WindSoilder 2023-09-26 20:53:59 +08:00 committed by GitHub
parent feef612388
commit d2f513da36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -331,8 +331,8 @@ pub fn eval_expression(
let lhs = eval_expression(engine_state, stack, expr)?;
match lhs {
Value::Bool { val, .. } => Ok(Value::bool(!val, expr.span)),
_ => Err(ShellError::TypeMismatch {
err_message: "bool".to_string(),
other => Err(ShellError::TypeMismatch {
err_message: format!("expected bool, found {}", other.get_type()),
span: expr.span,
}),
}