mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-08 01:47:48 +08:00
Add length also for too-many/few-args error
This commit is contained in:
parent
a3ee7da812
commit
c284c4ca99
|
@ -433,7 +433,9 @@ double state::base() {
|
||||||
|
|
||||||
std::vector<double> parameters;
|
std::vector<double> parameters;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; arity < 0 || i < arity; i++) {
|
const wchar_t *first_err = nullptr;
|
||||||
|
for (i = 0; ; i++) {
|
||||||
|
if (i == arity) first_err = next_;
|
||||||
parameters.push_back(expr());
|
parameters.push_back(expr());
|
||||||
if (type_ != TOK_SEP) {
|
if (type_ != TOK_SEP) {
|
||||||
break;
|
break;
|
||||||
|
@ -461,6 +463,13 @@ double state::base() {
|
||||||
// a closing parenthesis should be more obvious.
|
// a closing parenthesis should be more obvious.
|
||||||
error_ = i < arity ? TE_ERROR_TOO_FEW_ARGS : TE_ERROR_TOO_MANY_ARGS;
|
error_ = i < arity ? TE_ERROR_TOO_FEW_ARGS : TE_ERROR_TOO_MANY_ARGS;
|
||||||
type_ = TOK_ERROR;
|
type_ = TOK_ERROR;
|
||||||
|
if (first_err) {
|
||||||
|
errpos_ = first_err;
|
||||||
|
errlen_ = next_ - first_err;
|
||||||
|
// TODO: Rationalize where we put the cursor exactly.
|
||||||
|
// If we have a closing paren it's on it, if we don't it's before the number.
|
||||||
|
if (type_ != TOK_CLOSE) errlen_++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,6 +254,11 @@ math pow sin 3, 5
|
||||||
# CHECKERR: 'pow sin 3, 5'
|
# CHECKERR: 'pow sin 3, 5'
|
||||||
# CHECKERR: ^
|
# CHECKERR: ^
|
||||||
|
|
||||||
|
math pow sin 3, 5 + 2
|
||||||
|
# CHECKERR: math: Error: Too many arguments
|
||||||
|
# CHECKERR: 'pow sin 3, 5 + 2'
|
||||||
|
# CHECKERR: ^~~~^
|
||||||
|
|
||||||
math sin pow 3, 5
|
math sin pow 3, 5
|
||||||
# CHECK: -0.890009
|
# CHECK: -0.890009
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user