Mercurial > vim
diff src/testdir/test_vim9_expr.vim @ 23565:34aa2907082a v8.2.2325
patch 8.2.2325: Vim9: crash if map() changes the item type
Commit: https://github.com/vim/vim/commit/75ab91ff3403e725a79ac9c7351b78e9aff71d67
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 10 22:42:50 2021 +0100
patch 8.2.2325: Vim9: crash if map() changes the item type
Problem: Vim9: crash if map() changes the item type.
Solution: Check that the item type is still OK. (closes https://github.com/vim/vim/issues/7652)
Fix problem with mapnew() on range list.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 10 Jan 2021 22:45:06 +0100 |
parents | 647ff61c0bcd |
children | 455ad460ff4f |
line wrap: on
line diff
--- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -1859,10 +1859,10 @@ def Test_expr7_lambda() # line continuation inside lambda with "cond ? expr : expr" works var ll = range(3) - map(ll, (k, v) => v % 2 ? { + var dll = mapnew(ll, (k, v) => v % 2 ? { ['111']: 111 } : {} ) - assert_equal([{}, {111: 111}, {}], ll) + assert_equal([{}, {111: 111}, {}], dll) ll = range(3) map(ll, (k, v) => v == 8 || v @@ -1946,10 +1946,10 @@ def Test_expr7_new_lambda() # line continuation inside lambda with "cond ? expr : expr" works var ll = range(3) - map(ll, (k, v) => v % 2 ? { + var dll = mapnew(ll, (k, v) => v % 2 ? { ['111']: 111 } : {} ) - assert_equal([{}, {111: 111}, {}], ll) + assert_equal([{}, {111: 111}, {}], dll) ll = range(3) map(ll, (k, v) => v == 8 || v @@ -2964,25 +2964,25 @@ def Test_expr7_subscript_linebreak() var range = range( 3) var l = range - ->map('string(v:key)') + ->mapnew('string(v:key)') assert_equal(['0', '1', '2'], l) l = range - ->map('string(v:key)') + ->mapnew('string(v:key)') assert_equal(['0', '1', '2'], l) l = range # comment - ->map('string(v:key)') + ->mapnew('string(v:key)') assert_equal(['0', '1', '2'], l) l = range - ->map('string(v:key)') + ->mapnew('string(v:key)') assert_equal(['0', '1', '2'], l) l = range # comment - ->map('string(v:key)') + ->mapnew('string(v:key)') assert_equal(['0', '1', '2'], l) assert_equal('1', l[