eval: Fix setmatches(), setqflist() and setloclist()

This commit is contained in:
ZyX 2017-12-10 22:28:18 +03:00
parent f572bd7e4e
commit 5008205a3e
2 changed files with 87 additions and 93 deletions

View File

@ -14653,8 +14653,8 @@ skip_args:
title = (wp ? "setloclist()" : "setqflist()");
}
list_T *l = list_arg->vval.v_list;
if (l && set_errorlist(wp, l, action, (char_u *)title, d) == OK) {
list_T *const l = list_arg->vval.v_list;
if (set_errorlist(wp, l, action, (char_u *)title, d) == OK) {
rettv->vval.v_number = 0;
}
}
@ -14687,9 +14687,7 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
EMSG(_(e_listreq));
return;
}
list_T *l;
if ((l = argvars[0].vval.v_list) != NULL) {
list_T *const l = argvars[0].vval.v_list;
// To some extent make sure that we are dealing with a list from
// "getmatches()".
int i = 0;
@ -14774,7 +14772,6 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
rettv->vval.v_number = 0;
}
}
}
/*
* "setpos()" function

View File

@ -42,12 +42,6 @@ describe('NULL', function()
describe('list', function()
-- Incorrect behaviour
-- FIXME should return 0
null_expr_test('is accepted by setqflist()', 'setqflist(L)', 0, -1)
-- FIXME should return 0
null_expr_test('is accepted by setloclist()', 'setloclist(1, L)', 0, -1)
-- FIXME should return 0
null_expr_test('is accepted by setmatches()', 'setmatches(L)', 0, -1)
-- FIXME should not error out
null_test('is accepted by :cexpr', 'cexpr L', 'Vim(cexpr):E777: String or List expected')
-- FIXME should not error out
@ -129,6 +123,9 @@ describe('NULL', function()
'', '\n', function()
eq({''}, curbufmeths.get_lines(0, -1, false))
end)
null_expr_test('is accepted by setmatches()', 'setmatches(L)', 0, 0)
null_expr_test('is accepted by setqflist()', 'setqflist(L)', 0, 0)
null_expr_test('is accepted by setloclist()', 'setloclist(1, L)', 0, 0)
end)
describe('dict', function()
it('does not crash when indexing NULL dict', function()