patch 8.2.3793: using "g:Func" as a funcref does not work in script context

Problem:    Using "g:Func" as a funcref does not work in script context
            because "g:" is dropped.
Solution:   Keep "g:" in the name.  Also add parenthesis to avoid confusing
            operator prececence. (closes #9336)
diff --git a/src/evalvars.c b/src/evalvars.c
index a12b9bd..6aa2e42 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -1414,7 +1414,7 @@
 		n = (long)tv_get_number(tv);
 	}
 
-	if (opt_p_flags & P_FUNC && (tv->v_type == VAR_PARTIAL
+	if ((opt_p_flags & P_FUNC) && (tv->v_type == VAR_PARTIAL
 						|| tv->v_type == VAR_FUNC))
 	{
 	    // If the option can be set to a function reference or a lambda
@@ -2723,7 +2723,12 @@
 		if (rettv != NULL)
 		{
 		    rettv->v_type = VAR_FUNC;
-		    rettv->vval.v_string = vim_strsave(ufunc->uf_name);
+		    if (STRNCMP(name, "g:", 2) == 0)
+			// Keep the "g:", otherwise script-local may be
+			// assumed.
+			rettv->vval.v_string = vim_strsave(name);
+		    else
+			rettv->vval.v_string = vim_strsave(ufunc->uf_name);
 		    if (rettv->vval.v_string != NULL)
 			func_ref(ufunc->uf_name);
 		}