diff options
author | FlorianGit <f.v.kluck@gmail.com> | 2017-11-09 21:31:17 +0100 |
---|---|---|
committer | FlorianGit <f.v.kluck@gmail.com> | 2017-12-03 17:03:31 +0100 |
commit | d763d2fe7aae1c531c72c1d542cad2b19719929b (patch) | |
tree | e6a67626567f25519fc0ad73b409505a1422829d /src | |
parent | 27a577586eace687c47e7398845178208cae524a (diff) | |
download | rneovim-d763d2fe7aae1c531c72c1d542cad2b19719929b.tar.gz rneovim-d763d2fe7aae1c531c72c1d542cad2b19719929b.tar.bz2 rneovim-d763d2fe7aae1c531c72c1d542cad2b19719929b.zip |
Viml: Make filter and map handle null list correct
filter('v:_null_list, 'v:val') should return v:_null_list and a similar
statement should hold for map.
Changes after review
* Test inserted in legacy test suite has been removed by reverting the commit
adding it.
* Change the fix to tv_copy the argument before returning.
* Readd the two tests on crashes, and modified their expected return value.
* Move the test from 'incorrect behaviour' section to 'correct behaviour section'
* Add analogous tests for v:_null_dict
Always copy list or dictionary to return variable
If the type of input is correct (i.e. either a list or a dictionary), this
should also be returned.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 577aa67c60..56aedb1b4e 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -8457,11 +8457,13 @@ static void filter_map(typval_T *argvars, typval_T *rettv, int map) int idx = 0; if (argvars[0].v_type == VAR_LIST) { + tv_copy(&argvars[0], rettv); if ((l = argvars[0].vval.v_list) == NULL || (!map && tv_check_lock(l->lv_lock, arg_errmsg, TV_TRANSLATE))) { return; } } else if (argvars[0].v_type == VAR_DICT) { + tv_copy(&argvars[0], rettv); if ((d = argvars[0].vval.v_dict) == NULL || (!map && tv_check_lock(d->dv_lock, arg_errmsg, TV_TRANSLATE))) { return; @@ -8542,8 +8544,6 @@ static void filter_map(typval_T *argvars, typval_T *rettv, int map) did_emsg |= save_did_emsg; } - - tv_copy(&argvars[0], rettv); } static int filter_map_one(typval_T *tv, typval_T *expr, int map, int *remp) |