patch 8.2.5089: some functions return a different value on failure

Problem:    Some functions return a different value on failure.
Solution:   Initialize the return value earlier. (Yegappan Lakshmanan,
            closes #10568)
diff --git a/src/autocmd.c b/src/autocmd.c
index 71aeb50..841da14 100644
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -3062,6 +3062,8 @@
     char_u	*name = NULL;
     int		group = AUGROUP_ALL;
 
+    if (rettv_list_alloc(rettv) == FAIL)
+	return;
     if (check_for_opt_dict_arg(argvars, 0) == FAIL)
 	return;
 
@@ -3128,8 +3130,6 @@
 	}
     }
 
-    if (rettv_list_alloc(rettv) == FAIL)
-	return;
     event_list = rettv->vval.v_list;
 
     // iterate through all the autocmd events
diff --git a/src/dict.c b/src/dict.c
index 538dd8b..d281957 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -1457,6 +1457,9 @@
     dict_T	*d;
     int		todo;
 
+    if (rettv_list_alloc(rettv) == FAIL)
+	return;
+
     if (in_vim9script() && check_for_dict_arg(argvars, 0) == FAIL)
 	return;
 
@@ -1466,8 +1469,6 @@
 	return;
     }
 
-    if (rettv_list_alloc(rettv) == FAIL)
-	return;
     if ((d = argvars[0].vval.v_dict) == NULL)
 	// empty dict behaves like an empty dict
 	return;
diff --git a/src/evalfunc.c b/src/evalfunc.c
index ff30756..d85e854 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -8133,6 +8133,9 @@
     varnumber_T	stride = 1;
     int		error = FALSE;
 
+    if (rettv_list_alloc(rettv) != OK)
+	return;
+
     if (in_vim9script()
 	    && (check_for_number_arg(argvars, 0) == FAIL
 		|| check_for_opt_number_arg(argvars, 1) == FAIL
@@ -8159,7 +8162,7 @@
 	emsg(_(e_stride_is_zero));
     else if (stride > 0 ? end + 1 < start : end - 1 > start)
 	emsg(_(e_start_past_end));
-    else if (rettv_list_alloc(rettv) == OK)
+    else
     {
 	list_T *list = rettv->vval.v_list;
 
diff --git a/src/list.c b/src/list.c
index 50bf3af..b9a3478 100644
--- a/src/list.c
+++ b/src/list.c
@@ -1440,6 +1440,8 @@
     garray_T	ga;
     char_u	*sep;
 
+    rettv->v_type = VAR_STRING;
+
     if (in_vim9script()
 	    && (check_for_list_arg(argvars, 0) == FAIL
 		|| check_for_opt_string_arg(argvars, 1) == FAIL))
@@ -1450,7 +1452,7 @@
 	emsg(_(e_list_required));
 	return;
     }
-    rettv->v_type = VAR_STRING;
+
     if (argvars[0].vval.v_list == NULL)
 	return;
 
diff --git a/src/version.c b/src/version.c
index 02600f7..aa1319c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -735,6 +735,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    5089,
+/**/
     5088,
 /**/
     5087,