summaryrefslogtreecommitdiffstats
path: root/src/vim9compile.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-07-10 22:45:38 +0200
committerBram Moolenaar <Bram@vim.org>2020-07-10 22:45:38 +0200
commit543e6f3467f208930a5d7fadb82133334bf31356 (patch)
tree25b194a6701e6eab32449218d4f8dd0d6d93eb81 /src/vim9compile.c
parent7ff78465f7057a672a6de0d75d56286da253501b (diff)
patch 8.2.1176: Vim9: not enough type checking in Vim9 scriptv8.2.1176
Problem: Vim9: not enough type checking in Vim9 script. Solution: Use same type checking as in a :def function.
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r--src/vim9compile.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 3c0336ac4a..e7f90e1c7f 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -820,6 +820,14 @@ get_compare_isn(exptype_T exptype, vartype_T type1, vartype_T type2)
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, ppconst_T *ppconst)
// 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
{