diff src/vim9script.c @ 27217:facb54d20a50 v8.2.4137

patch 8.2.4137: Vim9: calling import with and without method is inconsistent Commit: https://github.com/vim/vim/commit/d02dce2bb572f0e6b4570442e9cdbed14ef41820 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 18 17:43:04 2022 +0000 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.
author Bram Moolenaar <Bram@vim.org>
date Tue, 18 Jan 2022 18:45:02 +0100
parents 5b54f413d132
children 018c911eb9cf
line wrap: on
line diff
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -707,22 +707,36 @@ find_exported(
 	    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;