mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 03:51:14 -03:00
math: Complain about unknown *function*, not *variable*
We removed variables from tinyexpr, so we shouldn't use that error.
This commit is contained in:
@@ -134,8 +134,8 @@ static const wchar_t *math_describe_error(te_error_t &error) {
|
||||
switch (error.type) {
|
||||
case TE_ERROR_NONE:
|
||||
DIE("Error has no position");
|
||||
case TE_ERROR_UNKNOWN_VARIABLE:
|
||||
return _(L"Unknown variable");
|
||||
case TE_ERROR_UNKNOWN_FUNCTION:
|
||||
return _(L"Unknown function");
|
||||
case TE_ERROR_MISSING_CLOSING_PAREN:
|
||||
return _(L"Missing closing parenthesis");
|
||||
case TE_ERROR_MISSING_OPENING_PAREN:
|
||||
|
||||
@@ -91,7 +91,7 @@ typedef struct state {
|
||||
te_error_type_t error;
|
||||
} state;
|
||||
|
||||
/* Parses the input expression and binds variables. */
|
||||
/* Parses the input expression. */
|
||||
/* Returns NULL on error. */
|
||||
te_expr *te_compile(const char *expression, te_error_t *error);
|
||||
|
||||
@@ -234,7 +234,7 @@ void next_token(state *s) {
|
||||
s->value = strtod(s->next, const_cast<char **>(&s->next));
|
||||
s->type = TOK_NUMBER;
|
||||
} else {
|
||||
/* Look for a variable or builtin function call. */
|
||||
/* Look for a function call. */
|
||||
// But not when it's an "x" followed by whitespace
|
||||
// - that's the alternative multiplication operator.
|
||||
if (s->next[0] >= 'a' && s->next[0] <= 'z' &&
|
||||
@@ -260,7 +260,7 @@ void next_token(state *s) {
|
||||
} else if (s->type != TOK_ERROR || s->error == TE_ERROR_UNKNOWN) {
|
||||
// Our error is more specific, so it takes precedence.
|
||||
s->type = TOK_ERROR;
|
||||
s->error = TE_ERROR_UNKNOWN_VARIABLE;
|
||||
s->error = TE_ERROR_UNKNOWN_FUNCTION;
|
||||
}
|
||||
} else {
|
||||
/* Look for an operator or special character. */
|
||||
@@ -329,7 +329,7 @@ static te_expr *expr(state *s);
|
||||
static te_expr *power(state *s);
|
||||
|
||||
static te_expr *base(state *s) {
|
||||
/* <base> = <constant> | <variable> | <function-0> {"(" ")"} | <function-1> <power> |
|
||||
/* <base> = <constant> | <function-0> {"(" ")"} | <function-1> <power> |
|
||||
* <function-X> "(" <expr> {"," <expr>} ")" | "(" <list> ")" */
|
||||
te_expr *ret;
|
||||
int arity;
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
typedef enum {
|
||||
TE_ERROR_NONE = 0,
|
||||
TE_ERROR_UNKNOWN_VARIABLE = 1,
|
||||
TE_ERROR_UNKNOWN_FUNCTION = 1,
|
||||
TE_ERROR_MISSING_CLOSING_PAREN = 2,
|
||||
TE_ERROR_MISSING_OPENING_PAREN = 3,
|
||||
TE_ERROR_TOO_FEW_ARGS = 4,
|
||||
|
||||
@@ -127,7 +127,7 @@ math 0x2 # Hex
|
||||
math 5 x 4
|
||||
math 2x 4
|
||||
math 2 x4 # ERROR
|
||||
# CHECKERR: math: Error: Unknown variable
|
||||
# CHECKERR: math: Error: Unknown function
|
||||
# CHECKERR: '2 x4'
|
||||
# CHECKERR: ^
|
||||
math 0x 3
|
||||
|
||||
Reference in New Issue
Block a user