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 #7652)
Fix problem with mapnew() on range list.
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index 8955a7c..50537c8 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -1859,10 +1859,10 @@
# 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 @@
# 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 @@
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[