mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 05:41:16 -03:00
[math] Better error for 2 -
Instead of the catch-all, report too few arguments.
This commit is contained in:
@@ -350,6 +350,17 @@ static te_expr *base(state *s) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TOK_END:
|
||||||
|
// The expression ended before we expected it.
|
||||||
|
// e.g. `2 - `.
|
||||||
|
// This means we have too few things.
|
||||||
|
// Instead of introducing another error, just call it
|
||||||
|
// "too few args".
|
||||||
|
ret = new_expr(0, 0);
|
||||||
|
s->type = TOK_ERROR;
|
||||||
|
s->error = TE_ERROR_TOO_FEW_ARGS;
|
||||||
|
ret->value = NAN;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ret = new_expr(0, 0);
|
ret = new_expr(0, 0);
|
||||||
s->type = TOK_ERROR;
|
s->type = TOK_ERROR;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
####################
|
####################
|
||||||
# Validate math error reporting
|
# Validate math error reporting
|
||||||
math: Error: Expression is bogus
|
math: Error: Too few arguments
|
||||||
'2 - '
|
'2 - '
|
||||||
^
|
^
|
||||||
math: Error: Too few arguments
|
math: Error: Too few arguments
|
||||||
|
|||||||
Reference in New Issue
Block a user