aboutsummaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-18 12:47:29 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-18 12:47:29 -0400
commitda4d07c6658f6b8189f98dfb051a7299fe45fb62 (patch)
treea452e26675e6fad1aa9e6147dc9bf57d1e08e6ad /types.c
parent752ab8212c7556ed714d1272582e57180b50c5a6 (diff)
Fix up some bigint logic issues
Diffstat (limited to 'types.c')
-rw-r--r--types.c15
1 files changed, 14 insertions, 1 deletions
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))