}
return p + 1;
}
-
+
return skip_var_one(arg, include_type);
}
// 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] == ':')
+ && (in_vim9script() || (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);
+ 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, *name, auto_name, TRUE);
+ ret = find_var_in_ht(ht, 'g', auto_name, TRUE);
vim_free(auto_name);
if (ret != NULL)
{
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
enddef
END
writefile(lines, 'Xdupdir/autoload/dup4func.vim')
- assert_fails('source Xdupdir/autoload/dup4func.vim', 'E707:')
+ assert_fails('source Xdupdir/autoload/dup4func.vim', 'E1041:')
lines =<< trim END
vim9script