From 2383d73645d0a72ea535e49899d9e35ac39a296d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 17 Aug 2024 15:14:45 -0400 Subject: Correct the logic to prevent promoting nums to ints automatically --- types.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'types.c') diff --git a/types.c b/types.c index a55395be..8e234948 100644 --- a/types.c +++ b/types.c @@ -269,8 +269,13 @@ bool can_promote(type_t *actual, type_t *needed) if (type_eq(actual, needed)) return true; - if ((actual->tag == IntType || actual->tag == NumType) - && (needed->tag == IntType || needed->tag == NumType)) { + if (actual->tag == NumType && needed->tag == IntType) + return false; + + if (actual->tag == IntType && needed->tag == NumType) + return true; + + if (actual->tag == IntType && needed->tag == IntType) { auto cmp = compare_precision(actual, needed); return cmp == NUM_PRECISION_EQUAL || cmp == NUM_PRECISION_LESS; } -- cgit v1.2.3