patch 8.2.1339: Vim9: assigning to global dict variable doesn't work

Problem:    Vim9: assigning to global dict variable doesn't work.
Solution:   Guess variable type based in index type. (issue #6591)
diff --git a/src/vim9compile.c b/src/vim9compile.c
index cae03d8..97fa2e0 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -5486,11 +5486,9 @@
 	    {
 		has_index = TRUE;
 		if (type->tt_member == NULL)
-		{
-		    semsg(_("E1088: cannot use an index on %s"), name);
-		    goto theend;
-		}
-		member_type = type->tt_member;
+		    member_type = &t_any;
+		else
+		    member_type = type->tt_member;
 	    }
 	    else
 	    {
@@ -5719,6 +5717,18 @@
 		emsg(_(e_missbrac));
 		goto theend;
 	    }
+	    if (type == &t_any)
+	    {
+		type_T	    *idx_type = ((type_T **)stack->ga_data)[
+							    stack->ga_len - 1];
+		// Index on variable of unknown type: guess the type from the
+		// index type: number is dict, otherwise dict.
+		// TODO: should do the assignment at runtime
+		if (idx_type->tt_type == VAR_NUMBER)
+		    type = &t_list_any;
+		else
+		    type = &t_dict_any;
+	    }
 	    if (type->tt_type == VAR_DICT
 		    && may_generate_2STRING(-1, cctx) == FAIL)
 		goto theend;