From da4d07c6658f6b8189f98dfb051a7299fe45fb62 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 18 Aug 2024 12:47:29 -0400 Subject: Fix up some bigint logic issues --- types.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'types.c') diff --git a/types.c b/types.c index d71da0e3..f666f667 100644 --- a/types.c +++ b/types.c @@ -273,7 +273,10 @@ bool can_promote(type_t *actual, type_t *needed) if (actual->tag == NumType && needed->tag == IntType) return false; - if (actual->tag == IntType && needed->tag == NumType) + if (actual->tag == IntType && (needed->tag == NumType || needed->tag == BigIntType)) + return true; + + if (actual->tag == BigIntType && needed->tag == NumType) return true; if (actual->tag == IntType && needed->tag == IntType) { @@ -402,6 +405,16 @@ bool can_have_cycles(type_t *t) return _can_have_cycles(t, &seen); } +bool is_int_type(type_t *t) +{ + return t->tag == IntType || t->tag == BigIntType; +} + +bool is_numeric_type(type_t *t) +{ + return t->tag == IntType || t->tag == BigIntType || t->tag == NumType; +} + type_t *replace_type(type_t *t, type_t *target, type_t *replacement) { if (type_eq(t, target)) -- cgit v1.2.3