diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-05 10:16:30 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-05 10:16:30 +0000 |
commit | c653e4a2bd4099e2fac8e1c448a0f34581d5a658 (patch) | |
tree | d4d5f0f8578e7377b4f895eb06301d6162826312 /src/eval.c | |
parent | a6f7929e62c19a6a2418a016b4c59b83eb1887ac (diff) | |
download | vim-git-c653e4a2bd4099e2fac8e1c448a0f34581d5a658.tar.gz |
patch 8.2.4006: Vim9: crash when declaring variable on the command linev8.2.4006
Problem: Vim9: crash when declaring variable on the command line.
Solution: Use a temporary type list. (closes #9474)
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/eval.c b/src/eval.c index a99d149a0..2e370c1b2 100644 --- a/src/eval.c +++ b/src/eval.c @@ -889,8 +889,9 @@ get_lval( } if (*p == ':') { - scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid); - char_u *tp = skipwhite(p + 1); + garray_T tmp_type_list; + garray_T *type_list; + char_u *tp = skipwhite(p + 1); if (tp == p + 1 && !quiet) { @@ -898,11 +899,26 @@ get_lval( return NULL; } + if (SCRIPT_ID_VALID(current_sctx.sc_sid)) + type_list = &SCRIPT_ITEM(current_sctx.sc_sid)->sn_type_list; + else + { + type_list = &tmp_type_list; + ga_init2(type_list, sizeof(type_T), 10); + } + // parse the type after the name - lp->ll_type = parse_type(&tp, &si->sn_type_list, !quiet); + lp->ll_type = parse_type(&tp, type_list, !quiet); if (lp->ll_type == NULL && !quiet) return NULL; lp->ll_name_end = tp; + + // drop the type when not in a script + if (type_list == &tmp_type_list) + { + lp->ll_type = NULL; + clear_type_list(type_list); + } } } } |