Mercurial > vim
diff src/vim9execute.c @ 20079:336483164ca6 v8.2.0595
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Commit: https://github.com/vim/vim/commit/a26b9700d73ebccd6c5459d0d66032a4249f6b72
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 18 19:53:28 2020 +0200
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Problem: Vim9: not all commands using ends_excmd() tested.
Solution: Find # comment after regular commands. Add more tests. Report
error for where it was caused.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 18 Apr 2020 20:00:04 +0200 |
parents | 4895e5cf1746 |
children | 7fc5d62fe2a5 |
line wrap: on
line diff
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -488,6 +488,7 @@ call_def_function( int idx; int ret = FAIL; int defcount = ufunc->uf_args.ga_len - argc; + int save_sc_version = current_sctx.sc_version; // Get pointer to item in the stack. #define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx) @@ -565,6 +566,9 @@ call_def_function( ectx.ec_instr = dfunc->df_instr; } + // Commands behave like vim9script. + current_sctx.sc_version = SCRIPT_VERSION_VIM9; + // Decide where to start execution, handles optional arguments. init_instr_idx(ufunc, argc, &ectx); @@ -582,6 +586,16 @@ call_def_function( did_throw = TRUE; } + if (did_emsg && msg_list != NULL && *msg_list != NULL) + { + // Turn an error message into an exception. + did_emsg = FALSE; + if (throw_exception(*msg_list, ET_ERROR, NULL) == FAIL) + goto failed; + did_throw = TRUE; + *msg_list = NULL; + } + if (did_throw && !ectx.ec_in_catch) { garray_T *trystack = &ectx.ec_trystack; @@ -1774,6 +1788,7 @@ failed: while (ectx.ec_frame != initial_frame_ptr) func_return(&ectx); failed_early: + current_sctx.sc_version = save_sc_version; for (idx = 0; idx < ectx.ec_stack.ga_len; ++idx) clear_tv(STACK_TV(idx)); vim_free(ectx.ec_stack.ga_data); @@ -1807,6 +1822,14 @@ ex_disassemble(exarg_T *eap) } ufunc = find_func(fname, NULL); + if (ufunc == NULL) + { + char_u *p = untrans_function_name(fname); + + if (p != NULL) + // Try again without making it script-local. + ufunc = find_func(p, NULL); + } vim_free(fname); if (ufunc == NULL) {