mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-07-01 16:31:16 -03:00
math: Report missing operators between the tokens
This affects the caret position. In an expression like
123 456
we previously reported:
123 456
^ missing operator
Now we do:
123 456
^ missing operator
We do it on the first space, which should be acceptable.
(no need for a changelog entry, we have already ignored #8511)
This commit is contained in:
@@ -375,6 +375,8 @@ static te_expr *base(state *s) {
|
||||
te_expr *ret;
|
||||
int arity;
|
||||
|
||||
auto previous = s->start;
|
||||
auto next = s->next;
|
||||
switch (s->type) {
|
||||
case TOK_NUMBER:
|
||||
ret = new_expr(TE_CONSTANT, nullptr);
|
||||
@@ -387,6 +389,12 @@ static te_expr *base(state *s) {
|
||||
// (of course 3 pi could also be interpreted as 3 x pi)
|
||||
s->type = TOK_ERROR;
|
||||
s->error = TE_ERROR_MISSING_OPERATOR;
|
||||
// The error should be given *between*
|
||||
// the last two tokens.
|
||||
// Since these are two separate numbers there is at least
|
||||
// one space between.
|
||||
s->start = previous;
|
||||
s->next = next + 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user