mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.3016: confusing error when expression is followed by comma
Problem: Confusing error when expression is followed by comma.
Solution: Give a different error for trailing text. (closes vim/vim#8395)
fae55a9cb0
Omit test_eval_stuff.vim and test_viminfo.vim: changes tests are N/A.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
fa2ed8ca1f
commit
7d7208a88b
@ -2277,10 +2277,15 @@ int eval0(char *arg, typval_T *rettv, char **nextcmd, int evaluate)
|
|||||||
char *p;
|
char *p;
|
||||||
const int did_emsg_before = did_emsg;
|
const int did_emsg_before = did_emsg;
|
||||||
const int called_emsg_before = called_emsg;
|
const int called_emsg_before = called_emsg;
|
||||||
|
bool end_error = false;
|
||||||
|
|
||||||
p = skipwhite(arg);
|
p = skipwhite(arg);
|
||||||
ret = eval1(&p, rettv, evaluate);
|
ret = eval1(&p, rettv, evaluate);
|
||||||
if (ret == FAIL || !ends_excmd(*p)) {
|
|
||||||
|
if (ret != FAIL) {
|
||||||
|
end_error = !ends_excmd(*p);
|
||||||
|
}
|
||||||
|
if (ret == FAIL || end_error) {
|
||||||
if (ret != FAIL) {
|
if (ret != FAIL) {
|
||||||
tv_clear(rettv);
|
tv_clear(rettv);
|
||||||
}
|
}
|
||||||
@ -2290,7 +2295,11 @@ int eval0(char *arg, typval_T *rettv, char **nextcmd, int evaluate)
|
|||||||
// Also check called_emsg for when using assert_fails().
|
// Also check called_emsg for when using assert_fails().
|
||||||
if (!aborting() && did_emsg == did_emsg_before
|
if (!aborting() && did_emsg == did_emsg_before
|
||||||
&& called_emsg == called_emsg_before) {
|
&& called_emsg == called_emsg_before) {
|
||||||
semsg(_(e_invexpr2), arg);
|
if (end_error) {
|
||||||
|
semsg(_(e_trailing_arg), p);
|
||||||
|
} else {
|
||||||
|
semsg(_(e_invexpr2), arg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
}
|
}
|
||||||
|
@ -297,6 +297,7 @@ func Test_let_errors()
|
|||||||
let ch = test_null_channel()
|
let ch = test_null_channel()
|
||||||
call assert_fails('let ch += 1', 'E734:')
|
call assert_fails('let ch += 1', 'E734:')
|
||||||
endif
|
endif
|
||||||
|
call assert_fails('let name = "a" .. "b",', 'E488: Trailing characters: ,')
|
||||||
|
|
||||||
" This test works only when the language is English
|
" This test works only when the language is English
|
||||||
if v:lang == "C" || v:lang =~ '^[Ee]n'
|
if v:lang == "C" || v:lang =~ '^[Ee]n'
|
||||||
|
@ -5569,7 +5569,7 @@ func Test_expr_eval_error_msg()
|
|||||||
call T(19, '{(1} + CONT(19)', 'E110', "Missing ')'")
|
call T(19, '{(1} + CONT(19)', 'E110', "Missing ')'")
|
||||||
call T(20, '("abc"[1) + CONT(20)', 'E111', "Missing ']'")
|
call T(20, '("abc"[1) + CONT(20)', 'E111', "Missing ']'")
|
||||||
call T(21, '(1 +) + CONT(21)', 'E15', "Invalid expression")
|
call T(21, '(1 +) + CONT(21)', 'E15', "Invalid expression")
|
||||||
call T(22, '1 2 + CONT(22)', 'E15', "Invalid expression")
|
call T(22, '1 2 + CONT(22)', 'E488', "Trailing characters: 2 +")
|
||||||
call T(23, '(1 ? 2) + CONT(23)', 'E109', "Missing ':' after '?'")
|
call T(23, '(1 ? 2) + CONT(23)', 'E109', "Missing ':' after '?'")
|
||||||
call T(24, '("abc) + CONT(24)', 'E114', "Missing quote")
|
call T(24, '("abc) + CONT(24)', 'E114', "Missing quote")
|
||||||
call T(25, "('abc) + CONT(25)", 'E115', "Missing quote")
|
call T(25, "('abc) + CONT(25)", 'E115', "Missing quote")
|
||||||
|
Loading…
Reference in New Issue
Block a user