aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compile.c3
-rw-r--r--types.c9
2 files changed, 10 insertions, 2 deletions
diff --git a/compile.c b/compile.c
index e15d8801..e8ed8c79 100644
--- a/compile.c
+++ b/compile.c
@@ -41,6 +41,9 @@ static bool promote(env_t *env, CORD *code, type_t *actual, type_t *needed)
return true;
}
+ if (actual->tag == NumType && needed->tag == IntType)
+ return false;
+
if (actual->tag == IntType || actual->tag == NumType)
return true;
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;
}