mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
Fix math
incorrect parenthesis error on missing term
This commit is contained in:
parent
326f5586de
commit
067b30208d
@ -147,6 +147,8 @@ static const wchar_t *math_describe_error(te_error_t &error) {
|
||||
return _(L"Too many arguments");
|
||||
case TE_ERROR_MISSING_OPERATOR:
|
||||
return _(L"Missing operator");
|
||||
case TE_ERROR_UNEXPECTED_TOKEN:
|
||||
return _(L"Unexpected token");
|
||||
case TE_ERROR_UNKNOWN:
|
||||
return _(L"Expression is bogus");
|
||||
default:
|
||||
|
@ -367,7 +367,7 @@ static te_expr *base(state *s) {
|
||||
}
|
||||
if (s->type == TOK_CLOSE && i == arity - 1) {
|
||||
next_token(s);
|
||||
} else if (s->type != TOK_ERROR || s->error == TE_ERROR_UNKNOWN) {
|
||||
} else if (s->type != TOK_ERROR || s->error == TE_ERROR_UNEXPECTED_TOKEN) {
|
||||
s->type = TOK_ERROR;
|
||||
s->error = i < arity ? TE_ERROR_TOO_FEW_ARGS : TE_ERROR_TOO_MANY_ARGS;
|
||||
}
|
||||
@ -403,7 +403,7 @@ static te_expr *base(state *s) {
|
||||
default:
|
||||
ret = new_expr(0, 0);
|
||||
s->type = TOK_ERROR;
|
||||
s->error = TE_ERROR_UNKNOWN;
|
||||
s->error = TE_ERROR_UNEXPECTED_TOKEN;
|
||||
ret->value = NAN;
|
||||
break;
|
||||
}
|
||||
|
@ -35,7 +35,8 @@ typedef enum {
|
||||
TE_ERROR_TOO_FEW_ARGS = 4,
|
||||
TE_ERROR_TOO_MANY_ARGS = 5,
|
||||
TE_ERROR_MISSING_OPERATOR = 6,
|
||||
TE_ERROR_UNKNOWN = 7
|
||||
TE_ERROR_UNEXPECTED_TOKEN = 7,
|
||||
TE_ERROR_UNKNOWN = 8
|
||||
} te_error_type_t;
|
||||
|
||||
typedef struct te_error_t {
|
||||
|
@ -91,7 +91,7 @@ not math 'ncr(1)'
|
||||
# CHECKERR: 'ncr(1)'
|
||||
# CHECKERR: ^
|
||||
not math 'max()'
|
||||
# CHECKERR: math: Error: Expression is bogus
|
||||
# CHECKERR: math: Error: Unexpected token
|
||||
# CHECKERR: 'max()'
|
||||
# CHECKERR: ^
|
||||
not math 'sin()'
|
||||
|
Loading…
x
Reference in New Issue
Block a user