[math] Better error for 2 -

Instead of the catch-all, report too few arguments.
This commit is contained in:
Fabian Homborg
2018-02-26 13:46:01 +01:00
parent 20af969aba
commit 6a38eb4f7d
2 changed files with 12 additions and 1 deletions

View File

@@ -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;

View File

@@ -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