To: vim_dev@googlegroups.com Subject: Patch 9.0.0744 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0744 Problem: In script in autoload dir exported variable is not found. (Doug Kearns) Solution: Find the variable with the "script#" prefix. (closes #11361) Files: src/evalvars.c, src/testdir/test_vim9_import.vim *** ../vim-9.0.0743/src/evalvars.c 2022-10-12 12:58:50.385618448 +0100 --- src/evalvars.c 2022-10-13 17:32:44.436833622 +0100 *************** *** 1326,1332 **** } return p + 1; } ! return skip_var_one(arg, include_type); } --- 1326,1332 ---- } return p + 1; } ! return skip_var_one(arg, include_type); } *************** *** 3160,3177 **** // When using "vim9script autoload" script-local items are prefixed but can // be used with s:name. if (SCRIPT_ID_VALID(current_sctx.sc_sid) ! && name[0] == 's' && name[1] == ':') { scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid); if (si->sn_autoload_prefix != NULL) { ! char_u *auto_name = concat_str(si->sn_autoload_prefix, name + 2); if (auto_name != NULL) { ht = &globvarht; ! ret = find_var_in_ht(ht, *name, auto_name, TRUE); vim_free(auto_name); if (ret != NULL) { --- 3160,3179 ---- // When using "vim9script autoload" script-local items are prefixed but can // be used with s:name. if (SCRIPT_ID_VALID(current_sctx.sc_sid) ! && (in_vim9script() || (name[0] == 's' && name[1] == ':'))) { scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid); if (si->sn_autoload_prefix != NULL) { ! char_u *base_name = (name[0] == 's' && name[1] == ':') ! ? name + 2 : name; ! char_u *auto_name = concat_str(si->sn_autoload_prefix, base_name); if (auto_name != NULL) { ht = &globvarht; ! ret = find_var_in_ht(ht, 'g', auto_name, TRUE); vim_free(auto_name); if (ret != NULL) { *** ../vim-9.0.0743/src/testdir/test_vim9_import.vim 2022-10-07 17:26:19.023293895 +0100 --- src/testdir/test_vim9_import.vim 2022-10-13 17:42:51.103837349 +0100 *************** *** 1218,1223 **** --- 1218,1243 ---- delete('Xa.vim') enddef + def Test_autoload_import_using_const() + mkdir('Xdir/autoload', 'pR') + var lines =<< trim END + vim9script + export const FOO = 42 + echomsg FOO + END + writefile(lines, 'Xdir/autoload/exp.vim') + + var save_rtp = &rtp + exe 'set rtp^=' .. getcwd() .. '/Xdir' + lines =<< trim END + vim9script + import autoload 'exp.vim' + assert_equal(42, exp.FOO) + END + v9.CheckScriptSuccess(lines) + &rtp = save_rtp + enddef + func Test_import_in_diffexpr() CheckExecutable diff *************** *** 2570,2576 **** enddef END writefile(lines, 'Xdupdir/autoload/dup4func.vim') ! assert_fails('source Xdupdir/autoload/dup4func.vim', 'E707:') lines =<< trim END vim9script --- 2590,2596 ---- enddef END writefile(lines, 'Xdupdir/autoload/dup4func.vim') ! assert_fails('source Xdupdir/autoload/dup4func.vim', 'E1041:') lines =<< trim END vim9script *** ../vim-9.0.0743/src/version.c 2022-10-13 16:34:27.130724804 +0100 --- src/version.c 2022-10-13 17:35:42.576521839 +0100 *************** *** 701,702 **** --- 701,704 ---- { /* Add new patch number below this line */ + /**/ + 744, /**/ -- Life is a gift, living is an art. (Bram Moolenaar) /// 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 ///