comparison src/vim9execute.c @ 21969:ba2415df82d7 v8.2.1534

patch 8.2.1534: Vim9: type error for argument type is not at call position Commit: https://github.com/vim/vim/commit/ee8580e52e767916e2a95e8ac0732fd8a5ae0651 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Aug 28 17:19:07 2020 +0200 patch 8.2.1534: Vim9: type error for argument type is not at call position Problem: Vim9: type error for argument type is not at call position. Solution: Set the context and stack after checking the arguments. (issue #6785)
author Bram Moolenaar <Bram@vim.org>
date Fri, 28 Aug 2020 17:30:04 +0200
parents 5edd776d886d
children 3fe594c72d8c
comparison
equal deleted inserted replaced
21968:613ecf205d6a 21969:ba2415df82d7
724 int initial_frame_idx; 724 int initial_frame_idx;
725 typval_T *tv; 725 typval_T *tv;
726 int idx; 726 int idx;
727 int ret = FAIL; 727 int ret = FAIL;
728 int defcount = ufunc->uf_args.ga_len - argc; 728 int defcount = ufunc->uf_args.ga_len - argc;
729 int save_sc_version = current_sctx.sc_version; 729 sctx_T save_current_sctx = current_sctx;
730 int breakcheck_count = 0; 730 int breakcheck_count = 0;
731 int called_emsg_before = called_emsg; 731 int called_emsg_before = called_emsg;
732 732
733 // Get pointer to item in the stack. 733 // Get pointer to item in the stack.
734 #define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx) 734 #define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx)
865 ectx.ec_stack.ga_len += count; 865 ectx.ec_stack.ga_len += count;
866 866
867 ectx.ec_instr = dfunc->df_instr; 867 ectx.ec_instr = dfunc->df_instr;
868 } 868 }
869 869
870 // Following errors are in the function, not the caller.
870 // Commands behave like vim9script. 871 // Commands behave like vim9script.
872 estack_push_ufunc(ufunc, 1);
873 current_sctx = ufunc->uf_script_ctx;
871 current_sctx.sc_version = SCRIPT_VERSION_VIM9; 874 current_sctx.sc_version = SCRIPT_VERSION_VIM9;
872 875
873 // Decide where to start execution, handles optional arguments. 876 // Decide where to start execution, handles optional arguments.
874 init_instr_idx(ufunc, argc, &ectx); 877 init_instr_idx(ufunc, argc, &ectx);
875 878
2612 2615
2613 failed: 2616 failed:
2614 // When failed need to unwind the call stack. 2617 // When failed need to unwind the call stack.
2615 while (ectx.ec_frame_idx != initial_frame_idx) 2618 while (ectx.ec_frame_idx != initial_frame_idx)
2616 func_return(&ectx); 2619 func_return(&ectx);
2620
2621 estack_pop();
2622 current_sctx = save_current_sctx;
2623
2617 failed_early: 2624 failed_early:
2618 current_sctx.sc_version = save_sc_version;
2619
2620 // Free all local variables, but not arguments. 2625 // Free all local variables, but not arguments.
2621 for (idx = 0; idx < ectx.ec_stack.ga_len; ++idx) 2626 for (idx = 0; idx < ectx.ec_stack.ga_len; ++idx)
2622 clear_tv(STACK_TV(idx)); 2627 clear_tv(STACK_TV(idx));
2623 2628
2624 vim_free(ectx.ec_stack.ga_data); 2629 vim_free(ectx.ec_stack.ga_data);