mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 12:28:39 +08:00
math: Add length to missing operator error
This commit is contained in:
parent
52e065e479
commit
a3ee7da812
|
@ -383,7 +383,6 @@ double state::base() {
|
|||
/* <base> = <constant> | <function-0> {"(" ")"} | <function-1> <power> |
|
||||
* <function-X> "(" <expr> {"," <expr>} ")" | "(" <list> ")" */
|
||||
|
||||
auto previous = start_;
|
||||
auto next = next_;
|
||||
switch (type_) {
|
||||
case TOK_NUMBER: {
|
||||
|
@ -398,10 +397,10 @@ double state::base() {
|
|||
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.
|
||||
start_ = previous;
|
||||
next_ = next + 1;
|
||||
errpos_ = next + 1;
|
||||
// Go to the end of whitespace.
|
||||
while (wcschr(L" \t\n\r", next++[0]));
|
||||
errlen_ = next - errpos_;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
|
|
@ -131,6 +131,11 @@ not math '2 + 2 4'
|
|||
# This regex to check whitespace - the error appears between the second 2 and the 4!
|
||||
# (right after the 2)
|
||||
# CHECKERR: {{^}} ^
|
||||
printf '<%s>\n' (math '2 + 2 4' 2>&1)
|
||||
# CHECK: <math: Error: Missing operator>
|
||||
# CHECK: <'2 + 2 4'>
|
||||
# CHECK: < ^~~~~^>
|
||||
|
||||
not math '(1 2)'
|
||||
# CHECKERR: math: Error: Missing operator
|
||||
# CHECKERR: '(1 2)'
|
||||
|
|
Loading…
Reference in New Issue
Block a user