comparison 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
comparison
equal deleted inserted replaced
20078:61222b5d173d 20079:336483164ca6
486 int initial_frame_ptr; 486 int initial_frame_ptr;
487 typval_T *tv; 487 typval_T *tv;
488 int idx; 488 int idx;
489 int ret = FAIL; 489 int ret = FAIL;
490 int defcount = ufunc->uf_args.ga_len - argc; 490 int defcount = ufunc->uf_args.ga_len - argc;
491 int save_sc_version = current_sctx.sc_version;
491 492
492 // Get pointer to item in the stack. 493 // Get pointer to item in the stack.
493 #define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx) 494 #define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx)
494 495
495 // Get pointer to item at the bottom of the stack, -1 is the bottom. 496 // Get pointer to item at the bottom of the stack, -1 is the bottom.
563 ectx.ec_stack.ga_len += dfunc->df_varcount; 564 ectx.ec_stack.ga_len += dfunc->df_varcount;
564 565
565 ectx.ec_instr = dfunc->df_instr; 566 ectx.ec_instr = dfunc->df_instr;
566 } 567 }
567 568
569 // Commands behave like vim9script.
570 current_sctx.sc_version = SCRIPT_VERSION_VIM9;
571
568 // Decide where to start execution, handles optional arguments. 572 // Decide where to start execution, handles optional arguments.
569 init_instr_idx(ufunc, argc, &ectx); 573 init_instr_idx(ufunc, argc, &ectx);
570 574
571 for (;;) 575 for (;;)
572 { 576 {
578 // Turn CTRL-C into an exception. 582 // Turn CTRL-C into an exception.
579 got_int = FALSE; 583 got_int = FALSE;
580 if (throw_exception("Vim:Interrupt", ET_INTERRUPT, NULL) == FAIL) 584 if (throw_exception("Vim:Interrupt", ET_INTERRUPT, NULL) == FAIL)
581 goto failed; 585 goto failed;
582 did_throw = TRUE; 586 did_throw = TRUE;
587 }
588
589 if (did_emsg && msg_list != NULL && *msg_list != NULL)
590 {
591 // Turn an error message into an exception.
592 did_emsg = FALSE;
593 if (throw_exception(*msg_list, ET_ERROR, NULL) == FAIL)
594 goto failed;
595 did_throw = TRUE;
596 *msg_list = NULL;
583 } 597 }
584 598
585 if (did_throw && !ectx.ec_in_catch) 599 if (did_throw && !ectx.ec_in_catch)
586 { 600 {
587 garray_T *trystack = &ectx.ec_trystack; 601 garray_T *trystack = &ectx.ec_trystack;
1772 failed: 1786 failed:
1773 // When failed need to unwind the call stack. 1787 // When failed need to unwind the call stack.
1774 while (ectx.ec_frame != initial_frame_ptr) 1788 while (ectx.ec_frame != initial_frame_ptr)
1775 func_return(&ectx); 1789 func_return(&ectx);
1776 failed_early: 1790 failed_early:
1791 current_sctx.sc_version = save_sc_version;
1777 for (idx = 0; idx < ectx.ec_stack.ga_len; ++idx) 1792 for (idx = 0; idx < ectx.ec_stack.ga_len; ++idx)
1778 clear_tv(STACK_TV(idx)); 1793 clear_tv(STACK_TV(idx));
1779 vim_free(ectx.ec_stack.ga_data); 1794 vim_free(ectx.ec_stack.ga_data);
1780 vim_free(ectx.ec_trystack.ga_data); 1795 vim_free(ectx.ec_trystack.ga_data);
1781 return ret; 1796 return ret;
1805 semsg(_(e_invarg2), eap->arg); 1820 semsg(_(e_invarg2), eap->arg);
1806 return; 1821 return;
1807 } 1822 }
1808 1823
1809 ufunc = find_func(fname, NULL); 1824 ufunc = find_func(fname, NULL);
1825 if (ufunc == NULL)
1826 {
1827 char_u *p = untrans_function_name(fname);
1828
1829 if (p != NULL)
1830 // Try again without making it script-local.
1831 ufunc = find_func(p, NULL);
1832 }
1810 vim_free(fname); 1833 vim_free(fname);
1811 if (ufunc == NULL) 1834 if (ufunc == NULL)
1812 { 1835 {
1813 semsg(_("E1061: Cannot find function %s"), eap->arg); 1836 semsg(_("E1061: Cannot find function %s"), eap->arg);
1814 return; 1837 return;