mirror of
https://github.com/neovim/neovim.git
synced 2025-12-04 21:52:41 +00:00
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user