comparison src/vim9script.c @ 23458:d2b1269c2c68 v8.2.2272

patch 8.2.2272: Vim9: extend() can violate the type of a variable Commit: https://github.com/vim/vim/commit/aa210a3aeccc33c6051978017959126b037f94af Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 2 15:41:03 2021 +0100 patch 8.2.2272: Vim9: extend() can violate the type of a variable Problem: Vim9: extend() can violate the type of a variable. Solution: Add the type to the dictionary or list and check items against it. (closes #7593)
author Bram Moolenaar <Bram@vim.org>
date Sat, 02 Jan 2021 15:45:04 +0100
parents 517fca70e084
children 85ce241ff9e3
comparison
equal deleted inserted replaced
23457:86b9697a8c63 23458:d2b1269c2c68
659 /* 659 /*
660 * Vim9 part of adding a script variable: add it to sn_all_vars (lookup by name 660 * Vim9 part of adding a script variable: add it to sn_all_vars (lookup by name
661 * with a hashtable) and sn_var_vals (lookup by index). 661 * with a hashtable) and sn_var_vals (lookup by index).
662 * When "create" is TRUE this is a new variable, otherwise find and update an 662 * When "create" is TRUE this is a new variable, otherwise find and update an
663 * existing variable. 663 * existing variable.
664 * When "type" is NULL use "tv" for the type. 664 * When "*type" is NULL use "tv" for the type and update "*type".
665 */ 665 */
666 void 666 void
667 update_vim9_script_var(int create, dictitem_T *di, typval_T *tv, type_T *type) 667 update_vim9_script_var(int create, dictitem_T *di, typval_T *tv, type_T **type)
668 { 668 {
669 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid); 669 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
670 hashitem_T *hi; 670 hashitem_T *hi;
671 svar_T *sv; 671 svar_T *sv;
672 672
713 { 713 {
714 sv = find_typval_in_script(&di->di_tv); 714 sv = find_typval_in_script(&di->di_tv);
715 } 715 }
716 if (sv != NULL) 716 if (sv != NULL)
717 { 717 {
718 if (type == NULL) 718 if (*type == NULL)
719 sv->sv_type = typval2type(tv, &si->sn_type_list); 719 *type = typval2type(tv, &si->sn_type_list);
720 else 720 sv->sv_type = *type;
721 sv->sv_type = type;
722 } 721 }
723 722
724 // let ex_export() know the export worked. 723 // let ex_export() know the export worked.
725 is_export = FALSE; 724 is_export = FALSE;
726 } 725 }