mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
eval: Fix add()
This commit is contained in:
parent
f4132fb38b
commit
1a961b5750
@ -6544,11 +6544,11 @@ static void f_abs(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
static void f_add(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
static void f_add(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
list_T *l;
|
list_T *l;
|
||||||
|
|
||||||
rettv->vval.v_number = 1; /* Default: Failed */
|
rettv->vval.v_number = 1; /* Default: Failed */
|
||||||
if (argvars[0].v_type == VAR_LIST) {
|
if (argvars[0].v_type == VAR_LIST) {
|
||||||
if ((l = argvars[0].vval.v_list) != NULL
|
if (!tv_check_lock(tv_list_locked((l = argvars[0].vval.v_list)),
|
||||||
&& !tv_check_lock(tv_list_locked(l), "add() argument", TV_TRANSLATE)) {
|
N_("add() argument"),
|
||||||
|
TV_TRANSLATE)) {
|
||||||
tv_list_append_tv(l, &argvars[1]);
|
tv_list_append_tv(l, &argvars[1]);
|
||||||
tv_copy(&argvars[0], rettv);
|
tv_copy(&argvars[0], rettv);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,8 @@ describe('NULL', function()
|
|||||||
null_expr_test('is accepted as an empty list by writefile()',
|
null_expr_test('is accepted as an empty list by writefile()',
|
||||||
('[writefile(L, "%s"), readfile("%s")]'):format(tmpfname, tmpfname),
|
('[writefile(L, "%s"), readfile("%s")]'):format(tmpfname, tmpfname),
|
||||||
0, {0, {}})
|
0, {0, {}})
|
||||||
null_expr_test('does not crash add()', 'add(L, 0)', 0, 1)
|
null_expr_test('makes add() error out', 'add(L, 0)',
|
||||||
|
'E742: Cannot change value of add() argument', 1)
|
||||||
null_expr_test('makes insert() error out', 'insert(L, 1)',
|
null_expr_test('makes insert() error out', 'insert(L, 1)',
|
||||||
'E742: Cannot change value of insert() argument', 0)
|
'E742: Cannot change value of insert() argument', 0)
|
||||||
null_expr_test('does not crash remove()', 'remove(L, 0)',
|
null_expr_test('does not crash remove()', 'remove(L, 0)',
|
||||||
|
Loading…
Reference in New Issue
Block a user