comparison src/vim9execute.c @ 21983:3fe594c72d8c v8.2.1541

patch 8.2.1541: Vim9: cannot find function reference for s:Func Commit: https://github.com/vim/vim/commit/95006e3dca099d3dc73d70d9872660308106e86c Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 29 17:47:08 2020 +0200 patch 8.2.1541: Vim9: cannot find function reference for s:Func Problem: Vim9: cannot find function reference for s:Func. Solution: Recognize <SNR> prefix. (closes https://github.com/vim/vim/issues/6805)
author Bram Moolenaar <Bram@vim.org>
date Sat, 29 Aug 2020 18:00:04 +0200
parents ba2415df82d7
children a9e60176dcd3
comparison
equal deleted inserted replaced
21982:8ffa48563456 21983:3fe594c72d8c
612 call_partial(typval_T *tv, int argcount_arg, ectx_T *ectx) 612 call_partial(typval_T *tv, int argcount_arg, ectx_T *ectx)
613 { 613 {
614 int argcount = argcount_arg; 614 int argcount = argcount_arg;
615 char_u *name = NULL; 615 char_u *name = NULL;
616 int called_emsg_before = called_emsg; 616 int called_emsg_before = called_emsg;
617 int res;
617 618
618 if (tv->v_type == VAR_PARTIAL) 619 if (tv->v_type == VAR_PARTIAL)
619 { 620 {
620 partial_T *pt = tv->vval.v_partial; 621 partial_T *pt = tv->vval.v_partial;
621 int i; 622 int i;
648 } 649 }
649 name = pt->pt_name; 650 name = pt->pt_name;
650 } 651 }
651 else if (tv->v_type == VAR_FUNC) 652 else if (tv->v_type == VAR_FUNC)
652 name = tv->vval.v_string; 653 name = tv->vval.v_string;
653 if (name == NULL || call_by_name(name, argcount, ectx, NULL) == FAIL) 654 if (name != NULL)
655 {
656 char_u fname_buf[FLEN_FIXED + 1];
657 char_u *tofree = NULL;
658 int error = FCERR_NONE;
659 char_u *fname;
660
661 // May need to translate <SNR>123_ to K_SNR.
662 fname = fname_trans_sid(name, fname_buf, &tofree, &error);
663 if (error != FCERR_NONE)
664 res = FAIL;
665 else
666 res = call_by_name(fname, argcount, ectx, NULL);
667 vim_free(tofree);
668 }
669
670 if (name == NULL || res == FAIL)
654 { 671 {
655 if (called_emsg == called_emsg_before) 672 if (called_emsg == called_emsg_before)
656 semsg(_(e_unknownfunc), 673 semsg(_(e_unknownfunc),
657 name == NULL ? (char_u *)"[unknown]" : name); 674 name == NULL ? (char_u *)"[unknown]" : name);
658 return FAIL; 675 return FAIL;