diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-08-17 15:14:45 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-08-17 15:14:45 -0400 |
| commit | 2383d73645d0a72ea535e49899d9e35ac39a296d (patch) | |
| tree | 0c354e9e11739fd1b94a65a64277999228acd3e4 /types.c | |
| parent | 37669b1734b7cc2daf3b1755c6a3c985adb896f8 (diff) | |
Correct the logic to prevent promoting nums to ints automatically
Diffstat (limited to 'types.c')
| -rw-r--r-- | types.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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; } |
