comparison src/evalvars.c @ 28231:66b245d84f37 v8.2.4642

patch 8.2.4642: Vim9: in :def function script var cannot be null Commit: https://github.com/vim/vim/commit/859cc21c6b60af07b549456b7d050a03b3e48bc9 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Mar 28 15:22:35 2022 +0100 patch 8.2.4642: Vim9: in :def function script var cannot be null Problem: Vim9: in :def function script var cannot be null. Solution: Only initialize a script variable when not set to a null value. (closes #10034)
author Bram Moolenaar <Bram@vim.org>
date Mon, 28 Mar 2022 16:30:03 +0200
parents 300b0ca4e46c
children fff70771d4bb
comparison
equal deleted inserted replaced
28230:1ef7f5e0c686 28231:66b245d84f37
2821 // declared. 2821 // declared.
2822 if (ht != &globvarht) 2822 if (ht != &globvarht)
2823 { 2823 {
2824 if (tv->v_type == VAR_DICT && tv->vval.v_dict == NULL 2824 if (tv->v_type == VAR_DICT && tv->vval.v_dict == NULL
2825 && ((type != NULL && type != &t_dict_empty) 2825 && ((type != NULL && type != &t_dict_empty)
2826 || !in_vim9script())) 2826 || !in_vim9script()))
2827 { 2827 {
2828 tv->vval.v_dict = dict_alloc(); 2828 tv->vval.v_dict = dict_alloc();
2829 if (tv->vval.v_dict != NULL) 2829 if (tv->vval.v_dict != NULL)
2830 { 2830 {
2831 ++tv->vval.v_dict->dv_refcount; 2831 ++tv->vval.v_dict->dv_refcount;
2841 { 2841 {
2842 ++tv->vval.v_list->lv_refcount; 2842 ++tv->vval.v_list->lv_refcount;
2843 tv->vval.v_list->lv_type = alloc_type(type); 2843 tv->vval.v_list->lv_type = alloc_type(type);
2844 } 2844 }
2845 } 2845 }
2846 else if (tv->v_type == VAR_BLOB && tv->vval.v_blob == NULL
2847 && ((type != NULL && type != &t_blob_null)
2848 || !in_vim9script()))
2849 {
2850 tv->vval.v_blob = blob_alloc();
2851 if (tv->vval.v_blob != NULL)
2852 ++tv->vval.v_blob->bv_refcount;
2853 }
2846 } 2854 }
2847 copy_tv(tv, rettv); 2855 copy_tv(tv, rettv);
2848 } 2856 }
2849 } 2857 }
2850 2858