To: vim_dev@googlegroups.com Subject: Patch 8.2.4176 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4176 Problem: Vim9: cannot use imported function with call(). Solution: Translate the function name. (closes #9590) Files: src/evalfunc.c, src/testdir/test_vim9_import.vim *** ../vim-8.2.4175/src/evalfunc.c 2022-01-22 10:24:43.643499627 +0000 --- src/evalfunc.c 2022-01-22 10:57:00.334861381 +0000 *************** *** 2929,2934 **** --- 2929,2936 ---- char_u *func; partial_T *partial = NULL; dict_T *selfdict = NULL; + char_u *dot; + char_u *tofree = NULL; if (in_vim9script() && (check_for_string_or_func_arg(argvars, 0) == FAIL *************** *** 2956,2961 **** --- 2958,2983 ---- if (func == NULL || *func == NUL) return; // type error, empty name or null function + dot = vim_strchr(func, '.'); + if (dot != NULL) + { + imported_T *import = find_imported(func, dot - func, TRUE, NULL); + + if (import != NULL && SCRIPT_ID_VALID(import->imp_sid)) + { + scriptitem_T *si = SCRIPT_ITEM(import->imp_sid); + + if (si->sn_autoload_prefix != NULL) + { + // Turn "import.Func" into "scriptname#Func". + tofree = concat_str(si->sn_autoload_prefix, dot + 1); + if (tofree == NULL) + return; + func = tofree; + } + } + } + if (argvars[2].v_type != VAR_UNKNOWN) { if (argvars[2].v_type != VAR_DICT) *************** *** 2967,2972 **** --- 2989,2996 ---- } (void)func_call(func, &argvars[1], partial, selfdict, rettv); + + vim_free(tofree); } /* *** ../vim-8.2.4175/src/testdir/test_vim9_import.vim 2022-01-21 20:37:02.287408821 +0000 --- src/testdir/test_vim9_import.vim 2022-01-22 10:56:09.335864312 +0000 *************** *** 706,712 **** edit! otherfile redraw ! set foldexpr= foldmethod& bwipe! delete('Xdir', 'rf') &rtp = save_rtp --- 706,712 ---- edit! otherfile redraw ! set foldexpr= foldmethod& debug= bwipe! delete('Xdir', 'rf') &rtp = save_rtp *************** *** 1525,1530 **** --- 1525,1532 ---- call another.Getother() assert_equal('other', g:result) + + assert_equal('arg', call('another.RetArg', ['arg'])) END CheckScriptSuccess(lines) *** ../vim-8.2.4175/src/version.c 2022-01-22 10:24:43.647499562 +0000 --- src/version.c 2022-01-22 10:49:11.100069096 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4176, /**/ -- An indication you must be a manager: You give constructive feedback to your dog. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///