harec

[hare] Hare compiler, written in C11 for POSIX OSs
Log | Files | Refs | README | LICENSE

commit b84c8ba483396a597fb57c5db9b0d764d2484632
parent 48817119540f0c220d85bafcd7e50b59626849fd
Author: Bor Grošelj Simić <bgs@turminal.net>
Date:   Sat, 18 Feb 2023 01:09:14 +0100

Revert "type_is_castable: fix enum case"

This reverts commit 48817119540f0c220d85bafcd7e50b59626849fd.

breaks hosted harec and doesn't handle rune enums correctly

Diffstat:
Msrc/types.c | 2+-
Mtests/26-regression.ha | 1-
2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/types.c b/src/types.c @@ -976,7 +976,7 @@ type_is_castable(const struct type *to, const struct type *from) return to->storage == STORAGE_U32 ? to_orig : NULL; case STORAGE_ENUM: - return to->storage == STORAGE_ENUM || type_is_integer(to) + return to->storage == STORAGE_ENUM || type_is_integer(from) ? to_orig : NULL; case STORAGE_F32: case STORAGE_F64: diff --git a/tests/26-regression.ha b/tests/26-regression.ha @@ -119,5 +119,4 @@ export fn main() void = { assert(rt::compile("fn a() *void = alloc(void);") as rt::exited != rt::EXIT_SUCCESS); assert(rt::compile("fn a() void = { static let b = x & struct { a: int = 0 }; };") as rt::exited != rt::EXIT_SUCCESS); let a: (size | mod::t) = 0; - assert(rt::compile("type a = enum { A }; fn b() *void = a::A: *void;") as rt::exited != rt::EXIT_SUCCESS); };