aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-13 02:45:57 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-13 02:45:57 -0400
commitab7a5e7af6e03f512964f47d75fb90f1b0de5f54 (patch)
tree1a18d95fac96ae83ab785aa06c08077a2b68cd62
parent9b9087bfef72417b4930512d33103d9a5a748cd8 (diff)
Proper promotion of ints
-rw-r--r--compile.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index 2766143c..8f796bb2 100644
--- a/compile.c
+++ b/compile.c
@@ -31,6 +31,11 @@ static bool promote(env_t *env, CORD *code, type_t *actual, type_t *needed)
if (!can_promote(actual, needed))
return false;
+ if (actual->tag == IntType && needed->tag == IntType && Match(needed, IntType)->bits == 0) {
+ *code = CORD_all("I(", *code, ")");
+ return true;
+ }
+
if (actual->tag == IntType || actual->tag == NumType)
return true;