patch 8.2.1870: Vim9: no need to keep all script variables

Problem:    Vim9: no need to keep all script variables.
Solution:   Only keep script variables when a function was defined that could
            use them.  Fix freeing static string on exit.
diff --git a/src/ex_eval.c b/src/ex_eval.c
index 22e83ae..3703690 100644
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -930,16 +930,22 @@
     {
 	scriptitem_T	*si = SCRIPT_ITEM(current_sctx.sc_sid);
 	int		i;
+	int		func_defined =
+			       cstack->cs_flags[cstack->cs_idx] & CSF_FUNC_DEF;
 
 	for (i = cstack->cs_script_var_len[cstack->cs_idx];
 					       i < si->sn_var_vals.ga_len; ++i)
 	{
 	    svar_T	*sv = ((svar_T *)si->sn_var_vals.ga_data) + i;
 
+	    // sv_name is set to NULL if it was already removed.  This happens
+	    // when it was defined in an inner block and no functions were
+	    // defined there.
 	    if (sv->sv_name != NULL)
 		// Remove a variable declared inside the block, if it still
-		// exists, from sn_vars and move the value into sn_all_vars.
-		hide_script_var(si, i);
+		// exists, from sn_vars and move the value into sn_all_vars
+		// if "func_defined" is non-zero.
+		hide_script_var(si, i, func_defined);
 	}
 
 	// TODO: is this needed?