Mercurial > vim
comparison src/testdir/test_vim9_builtin.vim @ 27867:1b75d767d9e4 v8.2.4459
patch 8.2.4459: Vim9: compiling sort() call fails with unknown arguments
Commit: https://github.com/vim/vim/commit/fa02616718103be3f9e13e26d57905d4eddf836d
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Feb 23 21:03:32 2022 +0000
patch 8.2.4459: Vim9: compiling sort() call fails with unknown arguments
Problem: Vim9: compiling sort() call fails with a funcref that has unknown
arguments.
Solution: Do not check the arguments if they are unknown at compile time.
(closes #9835)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 23 Feb 2022 22:15:03 +0100 |
parents | 05d222e5246a |
children | cc7d54a134e4 |
comparison
equal
deleted
inserted
replaced
27866:8ae06422a149 | 27867:1b75d767d9e4 |
---|---|
3810 | 3810 |
3811 lines =<< trim END | 3811 lines =<< trim END |
3812 sort([1, 2, 3], (a: any, b: any) => 1) | 3812 sort([1, 2, 3], (a: any, b: any) => 1) |
3813 END | 3813 END |
3814 v9.CheckDefAndScriptSuccess(lines) | 3814 v9.CheckDefAndScriptSuccess(lines) |
3815 | |
3816 lines =<< trim END | |
3817 vim9script | |
3818 def SortedList(): list<number> | |
3819 var Lambda: func: number = (a, b): number => a - b | |
3820 var l = [3, 2, 1] | |
3821 return l->sort(Lambda) | |
3822 enddef | |
3823 SortedList()->assert_equal([1, 2, 3]) | |
3824 END | |
3825 v9.CheckScriptSuccess(lines) | |
3815 enddef | 3826 enddef |
3816 | 3827 |
3817 def Test_sort_compare_func_fails() | 3828 def Test_sort_compare_func_fails() |
3818 v9.CheckDefAndScriptFailure(['sort("a")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1']) | 3829 v9.CheckDefAndScriptFailure(['sort("a")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1']) |
3819 v9.CheckDefAndScriptFailure(['sort([1], "", [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3']) | 3830 v9.CheckDefAndScriptFailure(['sort([1], "", [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3']) |