From fbc186e593126fc30560b96b93f88bad13ccf900 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 14 Dec 2023 03:36:18 +0200 Subject: [PATCH] float/double related implicit conversions --- self_hosted/runs_wrong.txt | 1 - self_hosted/typecheck.jou | 2 ++ self_hosted/types.jou | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/self_hosted/runs_wrong.txt b/self_hosted/runs_wrong.txt index b70c1d7a..876797fe 100644 --- a/self_hosted/runs_wrong.txt +++ b/self_hosted/runs_wrong.txt @@ -5,7 +5,6 @@ tests/other_errors/missing_value_in_return.jou tests/other_errors/noreturn_but_return_with_value.jou tests/other_errors/noreturn_but_return_without_value.jou tests/should_succeed/compiler_cli.jou -tests/should_succeed/implicit_conversions.jou tests/should_succeed/linked_list.jou tests/should_succeed/pointer.jou tests/should_succeed/printf.jou diff --git a/self_hosted/typecheck.jou b/self_hosted/typecheck.jou index d499dded..27e64fce 100644 --- a/self_hosted/typecheck.jou +++ b/self_hosted/typecheck.jou @@ -37,6 +37,8 @@ def can_cast_implicitly(from: Type*, to: Type*) -> bool: and from->size_in_bits < to->size_in_bits and not (from->kind == TypeKind::SignedInteger and to->kind == TypeKind::UnsignedInteger) ) + or (from == &float_type and to == &double_type) + or (from->is_integer_type() and to->kind == TypeKind::FloatingPoint) or (from->is_pointer_type() and to->is_pointer_type() and (from == &void_ptr_type or to == &void_ptr_type)) ) diff --git a/self_hosted/types.jou b/self_hosted/types.jou index e393048a..5656fa0e 100644 --- a/self_hosted/types.jou +++ b/self_hosted/types.jou @@ -66,7 +66,7 @@ class Type: # Pointers and arrays of a given type live as long as the type itself. # To make it possible, we just store them within the type. - # These are initially NULL and created in dynamically as needed. + # These are initially NULL and created dynamically as needed. # # Do not access these outside this file. cached_pointer_type: Type*