Mercurial > vim
comparison src/vim9execute.c @ 21481:279b3415947f v8.2.1291
patch 8.2.1291: Vim9: type of varargs items is not checked
Commit: https://github.com/vim/vim/commit/24aa48b7a265c24e18f0f978dfe0255e138e2b90
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 25 16:33:02 2020 +0200
patch 8.2.1291: Vim9: type of varargs items is not checked
Problem: Vim9: type of varargs items is not checked.
Solution: Check the list item types. (closes https://github.com/vim/vim/issues/6523)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 25 Jul 2020 16:45:04 +0200 |
parents | 66386ca8a69f |
children | 1c4d4aa22b37 |
comparison
equal
deleted
inserted
replaced
21480:440d226ff54a | 21481:279b3415947f |
---|---|
753 vararg_count = 0; | 753 vararg_count = 0; |
754 else | 754 else |
755 argc -= vararg_count; | 755 argc -= vararg_count; |
756 if (exe_newlist(vararg_count, &ectx) == FAIL) | 756 if (exe_newlist(vararg_count, &ectx) == FAIL) |
757 goto failed_early; | 757 goto failed_early; |
758 | |
759 // Check the type of the list items. | |
760 tv = STACK_TV_BOT(-1); | |
761 if (ufunc->uf_va_type != NULL | |
762 && ufunc->uf_va_type->tt_member != &t_any | |
763 && tv->vval.v_list != NULL) | |
764 { | |
765 type_T *expected = ufunc->uf_va_type->tt_member; | |
766 listitem_T *li = tv->vval.v_list->lv_first; | |
767 | |
768 for (idx = 0; idx < vararg_count; ++idx) | |
769 { | |
770 if (check_typval_type(expected, &li->li_tv) == FAIL) | |
771 goto failed_early; | |
772 li = li->li_next; | |
773 } | |
774 } | |
775 | |
758 if (defcount > 0) | 776 if (defcount > 0) |
759 // Move varargs list to below missing default arguments. | 777 // Move varargs list to below missing default arguments. |
760 *STACK_TV_BOT(defcount- 1) = *STACK_TV_BOT(-1); | 778 *STACK_TV_BOT(defcount - 1) = *STACK_TV_BOT(-1); |
761 --ectx.ec_stack.ga_len; | 779 --ectx.ec_stack.ga_len; |
762 } | 780 } |
763 | 781 |
764 // Make space for omitted arguments, will store default value below. | 782 // Make space for omitted arguments, will store default value below. |
765 // Any varargs list goes after them. | 783 // Any varargs list goes after them. |