diff options
| author | Bram Moolenaar <Bram@vim.org> | 2022-03-31 16:18:23 +0100 |
|---|---|---|
| committer | Bram Moolenaar <Bram@vim.org> | 2022-03-31 16:18:23 +0100 |
| commit | ccbfd4883f0385a1d84cc87785ddcc86185b4ad9 (patch) | |
| tree | 65f63c71b3792956985261e7ae0e4a02df0e9884 /src/vim9expr.c | |
| parent | 1104a6d0c2004d39e9b6cb8f804d12b628a69869 (diff) | |
| download | vim-git-8.2.4656.tar.gz | |
patch 8.2.4656: Vim9: can't use item from "import autoload" with autoload dirv8.2.4656
Problem: Vim9: can't use items from "import autoload" with autoload
directory name.
Solution: Let sn_autoload_prefix overrule sn_import_autoload.
(closes #10054)
Diffstat (limited to 'src/vim9expr.c')
| -rw-r--r-- | src/vim9expr.c | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/src/vim9expr.c b/src/vim9expr.c index 6576fc8ea..72bf1adbd 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -298,26 +298,31 @@ compile_load_scriptvar( *p = NUL; si = SCRIPT_ITEM(import->imp_sid); - if (si->sn_autoload_prefix != NULL - && si->sn_state == SN_STATE_NOT_LOADED) - { - char_u *auto_name = concat_str(si->sn_autoload_prefix, exp_name); + if (si->sn_import_autoload && si->sn_state == SN_STATE_NOT_LOADED) + // "import autoload './dir/script.vim'" or + // "import autoload './autoload/script.vim'" - load script first + res = generate_SOURCE(cctx, import->imp_sid); - // autoload script must be loaded later, access by the autoload - // name. If a '(' follows it must be a function. Otherwise we - // don't know, it can be "script.Func". - if (cc == '(' || paren_follows_after_expr) - res = generate_PUSHFUNC(cctx, auto_name, &t_func_any); - else - res = generate_AUTOLOAD(cctx, auto_name, &t_any); - vim_free(auto_name); - done = TRUE; - } - else if (si->sn_import_autoload && si->sn_state == SN_STATE_NOT_LOADED) + if (res == OK) { - // "import autoload './dir/script.vim'" - load script first - res = generate_SOURCE(cctx, import->imp_sid); - if (res == OK) + if (si->sn_autoload_prefix != NULL + && si->sn_state == SN_STATE_NOT_LOADED) + { + char_u *auto_name = + concat_str(si->sn_autoload_prefix, exp_name); + + // autoload script must be loaded later, access by the autoload + // name. If a '(' follows it must be a function. Otherwise we + // don't know, it can be "script.Func". + if (cc == '(' || paren_follows_after_expr) + res = generate_PUSHFUNC(cctx, auto_name, &t_func_any); + else + res = generate_AUTOLOAD(cctx, auto_name, &t_any); + vim_free(auto_name); + done = TRUE; + } + else if (si->sn_import_autoload + && si->sn_state == SN_STATE_NOT_LOADED) { // If a '(' follows it must be a function. Otherwise we don't // know, it can be "script.Func". @@ -331,14 +336,15 @@ compile_load_scriptvar( else res = generate_OLDSCRIPT(cctx, ISN_LOADEXPORT, exp_name, import->imp_sid, &t_any); + done = TRUE; + } + else + { + idx = find_exported(import->imp_sid, exp_name, &ufunc, &type, + cctx, NULL, TRUE); } - done = TRUE; - } - else - { - idx = find_exported(import->imp_sid, exp_name, &ufunc, &type, - cctx, NULL, TRUE); } + *p = cc; *end = p; if (done) |
