comparison src/vim9execute.c @ 21558:1c4d4aa22b37 v8.2.1329

patch 8.2.1329: Vim9: cannot define global function inside :def function Commit: https://github.com/vim/vim/commit/38ddf333f6b2806b0ea2dd052ee1cd50dd7f4525 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jul 31 22:05:04 2020 +0200 patch 8.2.1329: Vim9: cannot define global function inside :def function Problem: Vim9: cannot define global function inside :def function. Solution: Assign to global variable instead of local. (closes https://github.com/vim/vim/issues/6584)
author Bram Moolenaar <Bram@vim.org>
date Fri, 31 Jul 2020 22:15:04 +0200
parents 279b3415947f
children b8b15e8cbf5f
comparison
equal deleted inserted replaced
21557:00c9f8522652 21558:1c4d4aa22b37
721 { 721 {
722 // Check the function was really compiled. 722 // Check the function was really compiled.
723 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) 723 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
724 + ufunc->uf_dfunc_idx; 724 + ufunc->uf_dfunc_idx;
725 if (dfunc->df_instr == NULL) 725 if (dfunc->df_instr == NULL)
726 {
727 iemsg("using call_def_function() on not compiled function");
726 return FAIL; 728 return FAIL;
729 }
727 } 730 }
728 731
729 CLEAR_FIELD(ectx); 732 CLEAR_FIELD(ectx);
730 ectx.ec_dfunc_idx = ufunc->uf_dfunc_idx; 733 ectx.ec_dfunc_idx = ufunc->uf_dfunc_idx;
731 ga_init2(&ectx.ec_stack, sizeof(typval_T), 500); 734 ga_init2(&ectx.ec_stack, sizeof(typval_T), 500);
1724 tv->v_type = VAR_PARTIAL; 1727 tv->v_type = VAR_PARTIAL;
1725 tv->v_lock = 0; 1728 tv->v_lock = 0;
1726 } 1729 }
1727 break; 1730 break;
1728 1731
1732 // Create a global function from a lambda.
1733 case ISN_NEWFUNC:
1734 {
1735 newfunc_T *newfunc = &iptr->isn_arg.newfunc;
1736
1737 copy_func(newfunc->nf_lambda, newfunc->nf_global);
1738 }
1739 break;
1740
1729 // jump if a condition is met 1741 // jump if a condition is met
1730 case ISN_JUMP: 1742 case ISN_JUMP:
1731 { 1743 {
1732 jumpwhen_T when = iptr->isn_arg.jump.jump_when; 1744 jumpwhen_T when = iptr->isn_arg.jump.jump_when;
1733 int jump = TRUE; 1745 int jump = TRUE;
2907 dfunc_T *df = ((dfunc_T *)def_functions.ga_data) 2919 dfunc_T *df = ((dfunc_T *)def_functions.ga_data)
2908 + funcref->fr_func; 2920 + funcref->fr_func;
2909 2921
2910 smsg("%4d FUNCREF %s $%d", current, df->df_ufunc->uf_name, 2922 smsg("%4d FUNCREF %s $%d", current, df->df_ufunc->uf_name,
2911 funcref->fr_var_idx + dfunc->df_varcount); 2923 funcref->fr_var_idx + dfunc->df_varcount);
2924 }
2925 break;
2926
2927 case ISN_NEWFUNC:
2928 {
2929 newfunc_T *newfunc = &iptr->isn_arg.newfunc;
2930
2931 smsg("%4d NEWFUNC %s %s", current,
2932 newfunc->nf_lambda, newfunc->nf_global);
2912 } 2933 }
2913 break; 2934 break;
2914 2935
2915 case ISN_JUMP: 2936 case ISN_JUMP:
2916 { 2937 {