diff options
| author | Bram Moolenaar <Bram@vim.org> | 2022-03-28 15:22:35 +0100 |
|---|---|---|
| committer | Bram Moolenaar <Bram@vim.org> | 2022-03-28 15:22:35 +0100 |
| commit | 859cc21c6b60af07b549456b7d050a03b3e48bc9 (patch) | |
| tree | f2b27da6d782dc353fa52f8055b900b78997c6c7 /src/vim9script.c | |
| parent | 471b3aed3e9c43d4dd53444ceb74f9a4f8a3874a (diff) | |
| download | vim-git-859cc21c6b60af07b549456b7d050a03b3e48bc9.tar.gz | |
patch 8.2.4642: Vim9: in :def function script var cannot be nullv8.2.4642
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)
Diffstat (limited to 'src/vim9script.c')
| -rw-r--r-- | src/vim9script.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/vim9script.c b/src/vim9script.c index 3e8fe2f65..b793110b9 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -822,7 +822,7 @@ vim9_declare_scriptvar(exarg_T *eap, char_u *arg) init_tv.v_type = VAR_NUMBER; else init_tv.v_type = type->tt_type; - set_var_const(name, 0, type, &init_tv, FALSE, 0, 0); + set_var_const(name, 0, type, &init_tv, FALSE, ASSIGN_INIT, 0); vim_free(name); return p; @@ -925,6 +925,13 @@ update_vim9_script_var( if (*type == NULL) *type = typval2type(tv, get_copyID(), &si->sn_type_list, do_member ? TVTT_DO_MEMBER : 0); + else if ((flags & ASSIGN_INIT) == 0 + && (*type)->tt_type == VAR_BLOB && tv->v_type == VAR_BLOB + && tv->vval.v_blob == NULL) + { + // "var b: blob = null_blob" has a different type. + *type = &t_blob_null; + } if (sv->sv_type_allocated) free_type(sv->sv_type); if (*type != NULL && ((*type)->tt_type == VAR_FUNC |
