dfilter: Allow compatible types to be compared in min/max

This commit is contained in:
João Valverde 2022-12-27 04:53:40 +00:00
parent e85f8d4cf1
commit 6c1ee11172
3 changed files with 6 additions and 3 deletions

View File

@ -386,8 +386,8 @@ ul_semcheck_compare(dfwork_t *dfw, const char *func_name, ftenum_t lhs_ftype,
if (ftype == FT_NONE) {
ftype = ft_arg;
}
if (ft_arg != FT_NONE && ftype != FT_NONE && ft_arg != ftype) {
FAIL(dfw, arg, "Arguments to '%s' must have the same type (expected %s, got %s)",
if (ft_arg != FT_NONE && ftype != FT_NONE && !compatible_ftypes(ft_arg, ftype)) {
FAIL(dfw, arg, "Arguments to '%s' must be type compatible (expected %s, got %s)",
func_name, ftype_name(ftype), ftype_name(ft_arg));
}
if (ft_arg != FT_NONE && !ftype_can_cmp(ft_arg)) {

View File

@ -59,7 +59,7 @@ mk_fvalue_from_val_string(dfwork_t *dfw, header_field_info *hfinfo, const char *
/* Compares to ftenum_t's and decides if they're
* compatible or not (if they're the same basic type) */
static gboolean
gboolean
compatible_ftypes(ftenum_t a, ftenum_t b)
{
switch (a) {

View File

@ -22,4 +22,7 @@ check_arithmetic(dfwork_t *dfw, stnode_t *st_node, ftenum_t lhs_ftype);
ftenum_t
check_function(dfwork_t *dfw, stnode_t *st_node, ftenum_t lhs_ftype);
gboolean
compatible_ftypes(ftenum_t a, ftenum_t b);
#endif