From 6267996f13c5fd2ae8023b85c48e0e207e278cd9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Aug 2023 15:42:36 +0800 Subject: vim-patch:8.2.4455: accepting one and zero for second sort() argument is strange Problem: Accepting one and zero for the second sort() argument is strange. Solution: Disallow using one and zero in Vim9 script. https://github.com/vim/vim/commit/2007dd49f5cb36f944cab1cfbceb0f864e625f74 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_listdict.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/old/testdir/test_listdict.vim b/test/old/testdir/test_listdict.vim index 593fd12c1e..f2b4747ff2 100644 --- a/test/old/testdir/test_listdict.vim +++ b/test/old/testdir/test_listdict.vim @@ -887,7 +887,7 @@ func Test_reverse_sort_uniq() call assert_equal([-1, 'one', 'two', 'three', 'four', 1.0e-15, 0.22, 7, 9, 12, 18, 22, 255], sort(copy(l), 'n')) LET l = [7, 9, 18, 12, 22, 10.0e-16, -1, 0xff, 0, -0, 0.22, 'bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', {}, []] - call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 1)) + call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i')) call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i')) call assert_equal(['BAR', 'Bar', 'FOO', 'FOOBAR', 'Foo', 'bar', 'foo', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l))) endif @@ -899,6 +899,16 @@ func Test_reverse_sort_uniq() call assert_fails("call sort([1, 2], function('min'), 1)", "E1206:") call assert_fails("call sort([1, 2], function('invalid_func'))", "E700:") call assert_fails("call sort([1, 2], function('min'))", "E118:") + + let lines =<< trim END + call sort(['a', 'b'], 0) + END + call CheckDefAndScriptFailure(lines, 'E1256: String or function required for argument 2') + + let lines =<< trim END + call sort(['a', 'b'], 1) + END + call CheckDefAndScriptFailure(lines, 'E1256: String or function required for argument 2') endfunc " reduce a list, blob or string -- cgit