patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Problem: Vim9: calling import with and without method is inconsistent.
Solution: Set a flag that a parenthsis follows to compile_load_scriptvar().
Add some more tests. Improve error message.
diff --git a/src/vim9script.c b/src/vim9script.c
index 2f7f732..e13ac4a 100644
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -707,22 +707,36 @@
sprintf((char *)funcname + 3, "%ld_%s", (long)sid, name);
}
*ufunc = find_func(funcname, FALSE);
- if (funcname != buffer)
- vim_free(funcname);
if (*ufunc == NULL)
{
if (verbose)
- semsg(_(e_item_not_found_in_script_str), name);
- return -1;
+ {
+ ufunc_T *alt_ufunc = NULL;
+
+ if (script->sn_autoload_prefix != NULL)
+ {
+ // try find the function by the script-local name
+ funcname[0] = K_SPECIAL;
+ funcname[1] = KS_EXTRA;
+ funcname[2] = (int)KE_SNR;
+ sprintf((char *)funcname + 3, "%ld_%s", (long)sid, name);
+ alt_ufunc = find_func(funcname, FALSE);
+ }
+ if (alt_ufunc != NULL)
+ semsg(_(e_item_not_exported_in_script_str), name);
+ else
+ semsg(_(e_item_not_found_in_script_str), name);
+ }
}
else if (((*ufunc)->uf_flags & FC_EXPORT) == 0)
{
if (verbose)
semsg(_(e_item_not_exported_in_script_str), name);
*ufunc = NULL;
- return -1;
}
+ if (funcname != buffer)
+ vim_free(funcname);
}
return idx;