patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent

Problem:    Vim9: key type that can be used for literal dict and indexing is
            inconsistent.
Solution:   Allow using number and bool as key for a literal dict. (#7771)
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 5718efd..55e33eb 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -3145,7 +3145,6 @@
 compile_dict(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
 {
     garray_T	*instr = &cctx->ctx_instr;
-    garray_T	*stack = &cctx->ctx_type_stack;
     int		count = 0;
     dict_T	*d = dict_alloc();
     dictitem_T	*item;
@@ -3180,16 +3179,19 @@
 	    if (compile_expr0(arg, cctx) == FAIL)
 		return FAIL;
 	    isn = ((isn_T *)instr->ga_data) + instr->ga_len - 1;
+	    if (isn->isn_type == ISN_PUSHNR)
+	    {
+		char buf[NUMBUFLEN];
+
+		// Convert to string at compile time.
+		vim_snprintf(buf, NUMBUFLEN, "%lld", isn->isn_arg.number);
+		isn->isn_type = ISN_PUSHS;
+		isn->isn_arg.string = vim_strsave((char_u *)buf);
+	    }
 	    if (isn->isn_type == ISN_PUSHS)
 		key = isn->isn_arg.string;
-	    else
-	    {
-		type_T *keytype = ((type_T **)stack->ga_data)
-						       [stack->ga_len - 1];
-		if (need_type(keytype, &t_string, -1, 0, cctx,
-						     FALSE, FALSE) == FAIL)
-		    return FAIL;
-	    }
+	    else if (may_generate_2STRING(-1, cctx) == FAIL)
+		return FAIL;
 	    *arg = skipwhite(*arg);
 	    if (**arg != ']')
 	    {