patch 8.2.1176: Vim9: not enough type checking in Vim9 script

Problem:    Vim9: not enough type checking in Vim9 script.
Solution:   Use same type checking as in a :def function.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 3c0336a..e7f90e1 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -820,6 +820,14 @@
     return isntype;
 }
 
+    int
+check_compare_types(exptype_T type, typval_T *tv1, typval_T *tv2)
+{
+    if (get_compare_isn(type, tv1->v_type, tv2->v_type) == ISN_DROP)
+	return FAIL;
+    return OK;
+}
+
 /*
  * Generate an ISN_COMPARE* instruction with a boolean result.
  */
@@ -4296,7 +4304,7 @@
 	    // Both sides are a constant, compute the result now.
 	    // First check for a valid combination of types, this is more
 	    // strict than typval_compare().
-	    if (get_compare_isn(type, tv1->v_type, tv2->v_type) == ISN_DROP)
+	    if (check_compare_types(type, tv1, tv2) == FAIL)
 		ret = FAIL;
 	    else
 	    {