comparison src/vim9type.c @ 31551:67d9fbe516a3 v9.0.1108

patch 9.0.1108: type error when using "any" type and adding to float Commit: https://github.com/vim/vim/commit/c6951a76a58663ef8a773d340f2260da7455643c Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 29 20:56:24 2022 +0000 patch 9.0.1108: type error when using "any" type and adding to float Problem: Type error when using "any" type and adding a number to a float. Solution: Accept both a number and a float. (closes https://github.com/vim/vim/issues/11753)
author Bram Moolenaar <Bram@vim.org>
date Thu, 29 Dec 2022 22:00:04 +0100
parents 0c0ecf489f05
children c467d6e70972
comparison
equal deleted inserted replaced
31550:aadc3446d666 31551:67d9fbe516a3
811 { 811 {
812 if (expected->tt_type == VAR_BOOL 812 if (expected->tt_type == VAR_BOOL
813 && (actual->tt_flags & TTFLAG_BOOL_OK)) 813 && (actual->tt_flags & TTFLAG_BOOL_OK))
814 // Using number 0 or 1 for bool is OK. 814 // Using number 0 or 1 for bool is OK.
815 return OK; 815 return OK;
816 if (expected->tt_type == VAR_FLOAT
817 && (expected->tt_flags & TTFLAG_NUMBER_OK)
818 && actual->tt_type == VAR_NUMBER)
819 // Using number where float is expected is OK here.
820 return OK;
816 if (give_msg) 821 if (give_msg)
817 type_mismatch_where(expected, actual, where); 822 type_mismatch_where(expected, actual, where);
818 return FAIL; 823 return FAIL;
819 } 824 }
820 if (expected->tt_type == VAR_DICT || expected->tt_type == VAR_LIST) 825 if (expected->tt_type == VAR_DICT || expected->tt_type == VAR_LIST)
846 if (ret != FAIL && expected->tt_args != NULL 851 if (ret != FAIL && expected->tt_args != NULL
847 && actual->tt_args != NULL) 852 && actual->tt_args != NULL)
848 { 853 {
849 int i; 854 int i;
850 855
851 for (i = 0; i < expected->tt_argcount && i < actual->tt_argcount; ++i) 856 for (i = 0; i < expected->tt_argcount
857 && i < actual->tt_argcount; ++i)
852 // Allow for using "any" argument type, lambda's have them. 858 // Allow for using "any" argument type, lambda's have them.
853 if (actual->tt_args[i] != &t_any && check_type( 859 if (actual->tt_args[i] != &t_any && check_type(
854 expected->tt_args[i], actual->tt_args[i], FALSE, 860 expected->tt_args[i], actual->tt_args[i], FALSE,
855 where) == FAIL) 861 where) == FAIL)
856 { 862 {