Mirror of the Vim source from https://github.com/vim/vim
Revision | 5006d95ef82d3a6178ddaa728142ef53c5650864 (tree) |
---|---|
Zeit | 2021-03-09 06:00:03 |
Autor | Bram Moolenaar <Bram@vim....> |
Commiter | Bram Moolenaar |
patch 8.2.2580: Vim9: checking vararg type may be wrong
Commit: https://github.com/vim/vim/commit/e3ffcd9902efc756178900d9bd972c74a09c3fcd
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Mar 8 21:47:13 2021 +0100
@@ -3154,6 +3154,10 @@ | ||
3154 | 3154 | return 'test' |
3155 | 3155 | enddef |
3156 | 3156 | g:some#name = 'name' |
3157 | + | |
3158 | + def some#varargs(a1: string, ...l: list<string>): string | |
3159 | + return a1 .. l[0] .. l[1] | |
3160 | + enddef | |
3157 | 3161 | END |
3158 | 3162 | |
3159 | 3163 | mkdir('Xdir/autoload', 'p') |
@@ -3166,6 +3170,8 @@ | ||
3166 | 3170 | g:some#other = 'other' |
3167 | 3171 | assert_equal('other', g:some#other) |
3168 | 3172 | |
3173 | + assert_equal('abc', some#varargs('a', 'b', 'c')) | |
3174 | + | |
3169 | 3175 | # upper case script name works |
3170 | 3176 | lines =<< trim END |
3171 | 3177 | vim9script |
@@ -751,6 +751,8 @@ | ||
751 | 751 | static int included_patches[] = |
752 | 752 | { /* Add new patch number below this line */ |
753 | 753 | /**/ |
754 | + 2580, | |
755 | +/**/ | |
754 | 756 | 2579, |
755 | 757 | /**/ |
756 | 758 | 2578, |
@@ -807,9 +807,12 @@ | ||
807 | 807 | // types are correct. |
808 | 808 | for (i = 0; i < argcount; ++i) |
809 | 809 | { |
810 | - type_T *type = i < ufunc->uf_args.ga_len | |
811 | - ? ufunc->uf_arg_types[i] : ufunc->uf_va_type; | |
812 | - | |
810 | + type_T *type = NULL; | |
811 | + | |
812 | + if (i < ufunc->uf_args.ga_len) | |
813 | + type = ufunc->uf_arg_types[i]; | |
814 | + else if (ufunc->uf_va_type != NULL) | |
815 | + type = ufunc->uf_va_type->tt_member; | |
813 | 816 | if (type != NULL && check_typval_arg_type(type, |
814 | 817 | &argv[i], i + 1) == FAIL) |
815 | 818 | return FAIL; |