Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
21250:21fb2a3ad3ca | 21251:d1215fcdbca8 |
---|---|
816 semsg(_("E1072: Cannot compare %s with %s"), | 816 semsg(_("E1072: Cannot compare %s with %s"), |
817 vartype_name(type1), vartype_name(type2)); | 817 vartype_name(type1), vartype_name(type2)); |
818 return ISN_DROP; | 818 return ISN_DROP; |
819 } | 819 } |
820 return isntype; | 820 return isntype; |
821 } | |
822 | |
823 int | |
824 check_compare_types(exptype_T type, typval_T *tv1, typval_T *tv2) | |
825 { | |
826 if (get_compare_isn(type, tv1->v_type, tv2->v_type) == ISN_DROP) | |
827 return FAIL; | |
828 return OK; | |
821 } | 829 } |
822 | 830 |
823 /* | 831 /* |
824 * Generate an ISN_COMPARE* instruction with a boolean result. | 832 * Generate an ISN_COMPARE* instruction with a boolean result. |
825 */ | 833 */ |
4294 int ret; | 4302 int ret; |
4295 | 4303 |
4296 // Both sides are a constant, compute the result now. | 4304 // Both sides are a constant, compute the result now. |
4297 // First check for a valid combination of types, this is more | 4305 // First check for a valid combination of types, this is more |
4298 // strict than typval_compare(). | 4306 // strict than typval_compare(). |
4299 if (get_compare_isn(type, tv1->v_type, tv2->v_type) == ISN_DROP) | 4307 if (check_compare_types(type, tv1, tv2) == FAIL) |
4300 ret = FAIL; | 4308 ret = FAIL; |
4301 else | 4309 else |
4302 { | 4310 { |
4303 ret = typval_compare(tv1, tv2, type, ic); | 4311 ret = typval_compare(tv1, tv2, type, ic); |
4304 tv1->v_type = VAR_BOOL; | 4312 tv1->v_type = VAR_BOOL; |