mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
fix(eval): cherry-pick emsg changes from v8.1.0736
v8.1.0736 made some changes for making some emsgs more specific. Includes the change for Test_lambda_fails() in test_lambda.vim. Adjust relevant functionaltests to expect the new emsgs. This patch has been fully ported in my Blob port PR, but it hasn't been merged yet, so just use what we need from it for now. Required for v8.1.1821.
This commit is contained in:
parent
7d2233fad0
commit
e0bdc9b89c
@ -3162,6 +3162,8 @@ int eval0(char_u *arg, typval_T *rettv, char_u **nextcmd, int evaluate)
|
||||
{
|
||||
int ret;
|
||||
char_u *p;
|
||||
const int did_emsg_before = did_emsg;
|
||||
const int called_emsg_before = called_emsg;
|
||||
|
||||
p = skipwhite(arg);
|
||||
ret = eval1(&p, rettv, evaluate);
|
||||
@ -3171,8 +3173,10 @@ int eval0(char_u *arg, typval_T *rettv, char_u **nextcmd, int evaluate)
|
||||
}
|
||||
// Report the invalid expression unless the expression evaluation has
|
||||
// been cancelled due to an aborting error, an interrupt, or an
|
||||
// exception.
|
||||
if (!aborting()) {
|
||||
// exception, or we already gave a more specific error.
|
||||
// Also check called_emsg for when using assert_fails().
|
||||
if (!aborting() && did_emsg == did_emsg_before
|
||||
&& called_emsg == called_emsg_before) {
|
||||
emsgf(_(e_invexpr2), arg);
|
||||
}
|
||||
ret = FAIL;
|
||||
@ -9275,6 +9279,7 @@ void ex_echo(exarg_T *eap)
|
||||
bool atstart = true;
|
||||
bool need_clear = true;
|
||||
const int did_emsg_before = did_emsg;
|
||||
const int called_emsg_before = called_emsg;
|
||||
|
||||
if (eap->skip)
|
||||
++emsg_skip;
|
||||
@ -9289,7 +9294,8 @@ void ex_echo(exarg_T *eap)
|
||||
// Report the invalid expression unless the expression evaluation
|
||||
// has been cancelled due to an aborting error, an interrupt, or an
|
||||
// exception.
|
||||
if (!aborting() && did_emsg == did_emsg_before) {
|
||||
if (!aborting() && did_emsg == did_emsg_before
|
||||
&& called_emsg == called_emsg_before) {
|
||||
EMSG2(_(e_invexpr2), p);
|
||||
}
|
||||
need_clr_eos = false;
|
||||
|
@ -61,7 +61,7 @@ endfunction
|
||||
|
||||
function Test_lambda_fails()
|
||||
call assert_equal(3, {a, b -> a + b}(1, 2))
|
||||
call assert_fails('echo {a, a -> a + a}(1, 2)', 'E15:')
|
||||
call assert_fails('echo {a, a -> a + a}(1, 2)', 'E853:')
|
||||
call assert_fails('echo {a, b -> a + b)}(1, 2)', 'E15:')
|
||||
endfunc
|
||||
|
||||
|
@ -247,9 +247,9 @@ describe('startup', function()
|
||||
[[" -u NONE -i NONE --cmd "set noruler" --cmd "let g:foo = g:bar"')]])
|
||||
screen:expect([[
|
||||
^ |
|
||||
|
|
||||
Error detected while processing pre-vimrc command line: |
|
||||
E121: Undefined variable: g:bar |
|
||||
E15: Invalid expression: g:bar |
|
||||
Press ENTER or type command to continue |
|
||||
|
|
||||
]])
|
||||
|
@ -53,7 +53,7 @@ describe('NULL', function()
|
||||
|
||||
-- Correct behaviour
|
||||
null_expr_test('can be indexed with error message for empty list', 'L[0]',
|
||||
'E684: list index out of range: 0\nE15: Invalid expression: L[0]', nil)
|
||||
'E684: list index out of range: 0', nil)
|
||||
null_expr_test('can be splice-indexed', 'L[:]', 0, {})
|
||||
null_expr_test('is not locked', 'islocked("v:_null_list")', 0, 0)
|
||||
null_test('is accepted by :for', 'for x in L|throw x|endfor', 0)
|
||||
@ -68,7 +68,7 @@ describe('NULL', function()
|
||||
null_expr_test('can be copied', 'copy(L)', 0, {})
|
||||
null_expr_test('can be deepcopied', 'deepcopy(L)', 0, {})
|
||||
null_expr_test('does not crash when indexed', 'L[1]',
|
||||
'E684: list index out of range: 1\nE15: Invalid expression: L[1]', nil)
|
||||
'E684: list index out of range: 1', nil)
|
||||
null_expr_test('does not crash call()', 'call("arglistid", L)', 0, 0)
|
||||
null_expr_test('does not crash col()', 'col(L)', 0, 0)
|
||||
null_expr_test('does not crash virtcol()', 'virtcol(L)', 0, 0)
|
||||
@ -135,7 +135,7 @@ describe('NULL', function()
|
||||
end)
|
||||
describe('dict', function()
|
||||
it('does not crash when indexing NULL dict', function()
|
||||
eq('\nE716: Key not present in Dictionary: "test"\nE15: Invalid expression: v:_null_dict.test',
|
||||
eq('\nE716: Key not present in Dictionary: "test"',
|
||||
redir_exec('echo v:_null_dict.test'))
|
||||
end)
|
||||
null_expr_test('makes extend error out', 'extend(D, {})', 'E742: Cannot change value of extend() argument', 0)
|
||||
|
@ -653,14 +653,12 @@ describe('clipboard (with fake clipboard.vim)', function()
|
||||
'',
|
||||
'',
|
||||
'E121: Undefined variable: doesnotexist',
|
||||
'E15: Invalid expression: doesnotexist',
|
||||
}, 'v'}, eval("g:test_clip['*']"))
|
||||
feed_command(':echo "Howdy!"')
|
||||
eq({{
|
||||
'',
|
||||
'',
|
||||
'E121: Undefined variable: doesnotexist',
|
||||
'E15: Invalid expression: doesnotexist',
|
||||
'',
|
||||
'Howdy!',
|
||||
}, 'v'}, eval("g:test_clip['*']"))
|
||||
|
Loading…
Reference in New Issue
Block a user