patch 8.2.1426: Vim9: cannot call autoload function in :def function

Problem:    Vim9: cannot call autoload function in :def function.
Solution:   Load the autoload script. (closes #6690)
diff --git a/src/vim9execute.c b/src/vim9execute.c
index 6e9b53d..fed7fed 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -546,6 +546,15 @@
 }
 
 /*
+ * Return TRUE if an error was given or CTRL-C was pressed.
+ */
+    static int
+vim9_aborting(int prev_called_emsg)
+{
+    return called_emsg > prev_called_emsg || got_int || did_throw;
+}
+
+/*
  * Execute a function by "name".
  * This can be a builtin function or a user function.
  * "iptr" can be used to replace the instruction with a more efficient one.
@@ -568,6 +577,18 @@
     }
 
     ufunc = find_func(name, FALSE, NULL);
+
+    if (ufunc == NULL)
+    {
+	int called_emsg_before = called_emsg;
+
+	if (script_autoload(name, TRUE))
+	    // loaded a package, search for the function again
+	    ufunc = find_func(name, FALSE, NULL);
+	if (vim9_aborting(called_emsg_before))
+	    return FAIL;  // bail out if loading the script caused an error
+    }
+
     if (ufunc != NULL)
 	return call_ufunc(ufunc, argcount, ectx, iptr);