Mercurial > vim
comparison src/testdir/test_vim9_assign.vim @ 26833:434eaef2ac62 v8.2.3945
patch 8.2.3945: Vim9: partial variable argument types are wrong
Commit: https://github.com/vim/vim/commit/13789bf10338a0d049c78acfdc0870fc63e63f4f
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Dec 30 13:29:00 2021 +0000
patch 8.2.3945: Vim9: partial variable argument types are wrong
Problem: Vim9: partial variable argument types are wrong, leading to a
crash.
Solution: When adjusting the argument count also adjust the argument types.
(closes #9433)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 30 Dec 2021 14:30:04 +0100 |
parents | a07323eb647f |
children | 15913ba6363e |
comparison
equal
deleted
inserted
replaced
26832:eb188d6e2e41 | 26833:434eaef2ac62 |
---|---|
845 var Ref: func = function(Func, [true]) | 845 var Ref: func = function(Func, [true]) |
846 assert_equal('func()', typename(Ref)) | 846 assert_equal('func()', typename(Ref)) |
847 Ref() | 847 Ref() |
848 END | 848 END |
849 CheckScriptSuccess(lines) | 849 CheckScriptSuccess(lines) |
850 | |
851 lines =<< trim END | |
852 vim9script | |
853 | |
854 var nres: any | |
855 var sres: any | |
856 def Func(n: number, s = '') | |
857 nres = n | |
858 sres = s | |
859 enddef | |
860 | |
861 var n: number | |
862 var Ref = function(Func, [n]) | |
863 Ref('x') | |
864 assert_equal(0, nres) | |
865 assert_equal('x', sres) | |
866 END | |
867 CheckScriptSuccess(lines) | |
868 | |
869 lines =<< trim END | |
870 vim9script | |
871 | |
872 def Func(n: number, s = '') | |
873 enddef | |
874 | |
875 var n: number | |
876 var Ref = function(Func, [n]) | |
877 Ref(0) | |
878 END | |
879 CheckScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected string but got number') | |
850 enddef | 880 enddef |
851 | 881 |
852 def Test_assignment_list_any_index() | 882 def Test_assignment_list_any_index() |
853 var l: list<number> = [1, 2] | 883 var l: list<number> = [1, 2] |
854 for [x, y, _] | 884 for [x, y, _] |