Mercurial > vim
diff src/testdir/test_filter_map.vim @ 19233:04c164c971a3 v8.2.0175
patch 8.2.0175: crash when removing list element in map()
Commit: https://github.com/vim/vim/commit/db661fb95dc41b7a9438cf3cd4e77f8410bc81c0
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 29 22:17:16 2020 +0100
patch 8.2.0175: crash when removing list element in map()
Problem: Crash when removing list element in map().
Solution: Lock the list. (closes https://github.com/vim/vim/issues/2652)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 29 Jan 2020 22:30:04 +0100 |
parents | 745c02392844 |
children | e82996ad131f |
line wrap: on
line diff
--- a/src/testdir/test_filter_map.vim +++ b/src/testdir/test_filter_map.vim @@ -93,3 +93,13 @@ func Test_map_fails() call assert_fails('call map([1], "42 +")', 'E15:') call assert_fails('call filter([1], "42 +")', 'E15:') endfunc + +func Test_map_and_modify() + let l = ["abc"] + " cannot change the list halfway a map() + call assert_fails('call map(l, "remove(l, 0)[0]")', 'E741:') + + let d = #{a: 1, b: 2, c: 3} + call assert_fails('call map(d, "remove(d, v:key)[0]")', 'E741:') + call assert_fails('echo map(d, {k,v -> remove(d, k)})', 'E741:') +endfunc