diff src/vim9compile.c @ 21251:d1215fcdbca8 v8.2.1176

patch 8.2.1176: Vim9: not enough type checking in Vim9 script Commit: https://github.com/vim/vim/commit/543e6f3467f208930a5d7fadb82133334bf31356 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jul 10 22:45:38 2020 +0200 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.
author Bram Moolenaar <Bram@vim.org>
date Fri, 10 Jul 2020 23:00:03 +0200
parents 4edc60c9c0aa
children 4be91a7eafb2
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -820,6 +820,14 @@ get_compare_isn(exptype_T exptype, varty
     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 @@ compile_expr4(char_u **arg, cctx_T *cctx
 	    // 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
 	    {