Mercurial > vim
comparison src/testdir/test_vim9_func.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 | 64dfb69e7d46 |
children | ca98d85e92da |
comparison
equal
deleted
inserted
replaced
23564:469359887d3e | 23565:34aa2907082a |
---|---|
1761 CheckScriptSuccess(lines) | 1761 CheckScriptSuccess(lines) |
1762 enddef | 1762 enddef |
1763 | 1763 |
1764 def Shadowed(): list<number> | 1764 def Shadowed(): list<number> |
1765 var FuncList: list<func: number> = [() => 42] | 1765 var FuncList: list<func: number> = [() => 42] |
1766 return FuncList->map((_, Shadowed) => Shadowed()) | 1766 return FuncList->mapnew((_, Shadowed) => Shadowed()) |
1767 enddef | 1767 enddef |
1768 | 1768 |
1769 def Test_lambda_arg_shadows_func() | 1769 def Test_lambda_arg_shadows_func() |
1770 assert_equal([42], Shadowed()) | 1770 assert_equal([42], Shadowed()) |
1771 enddef | 1771 enddef |
1790 CheckScriptSuccess(lines) | 1790 CheckScriptSuccess(lines) |
1791 enddef | 1791 enddef |
1792 | 1792 |
1793 def Line_continuation_in_lambda(): list<string> | 1793 def Line_continuation_in_lambda(): list<string> |
1794 var x = range(97, 100) | 1794 var x = range(97, 100) |
1795 ->map((_, v) => nr2char(v) | 1795 ->mapnew((_, v) => nr2char(v) |
1796 ->toupper()) | 1796 ->toupper()) |
1797 ->reverse() | 1797 ->reverse() |
1798 return x | 1798 return x |
1799 enddef | 1799 enddef |
1800 | 1800 |
1906 def Test_recursive_call() | 1906 def Test_recursive_call() |
1907 Fibonacci(20)->assert_equal(6765) | 1907 Fibonacci(20)->assert_equal(6765) |
1908 enddef | 1908 enddef |
1909 | 1909 |
1910 def TreeWalk(dir: string): list<any> | 1910 def TreeWalk(dir: string): list<any> |
1911 return readdir(dir)->map((_, val) => | 1911 return readdir(dir)->mapnew((_, val) => |
1912 fnamemodify(dir .. '/' .. val, ':p')->isdirectory() | 1912 fnamemodify(dir .. '/' .. val, ':p')->isdirectory() |
1913 ? {[val]: TreeWalk(dir .. '/' .. val)} | 1913 ? {[val]: TreeWalk(dir .. '/' .. val)} |
1914 : val | 1914 : val |
1915 ) | 1915 ) |
1916 enddef | 1916 enddef |