Mercurial > vim
diff src/vim9type.c @ 28002:1012048eed26 v8.2.4526
patch 8.2.4526: Vim9: cannot set variables to a null value
Commit: https://github.com/vim/vim/commit/8acb9cc6209768ca7ec75c9f7af8c389312ea8d6
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Mar 8 13:18:55 2022 +0000
patch 8.2.4526: Vim9: cannot set variables to a null value
Problem: Vim9: cannot set variables to a null value.
Solution: Add null_list, null_job, etc.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 08 Mar 2022 14:30:05 +0100 |
parents | 292a6bd86c30 |
children | cc7d54a134e4 |
line wrap: on
line diff
--- a/src/vim9type.c +++ b/src/vim9type.c @@ -567,22 +567,19 @@ check_typval_type(type_T *expected, typv if (expected == NULL) return OK; // didn't expect anything. + // + ga_init2(&type_list, sizeof(type_T *), 10); - // For some values there is no type, assume an error will be given later - // for an invalid value. + // A null_function and null_partial are special cases, they can be used to + // clear a variable. if ((actual_tv->v_type == VAR_FUNC && actual_tv->vval.v_string == NULL) || (actual_tv->v_type == VAR_PARTIAL && actual_tv->vval.v_partial == NULL)) - { - emsg(_(e_function_reference_is_not_set)); - return FAIL; - } - - ga_init2(&type_list, sizeof(type_T *), 10); - - // When the actual type is list<any> or dict<any> go through the values to - // possibly get a more specific type. - actual_type = typval2type(actual_tv, get_copyID(), &type_list, + actual_type = &t_func_unknown; + else + // When the actual type is list<any> or dict<any> go through the values + // to possibly get a more specific type. + actual_type = typval2type(actual_tv, get_copyID(), &type_list, TVTT_DO_MEMBER | TVTT_MORE_SPECIFIC); if (actual_type != NULL) {