commit 48817119540f0c220d85bafcd7e50b59626849fd
parent e74d1aa3d691b0606c4cd5afd650dd5f1a563867
Author: Ember Sawady <ecs@d2evs.net>
Date: Thu, 16 Feb 2023 04:11:51 +0000
type_is_castable: fix enum case
Signed-off-by: Ember Sawady <ecs@d2evs.net>
Diffstat:
2 files changed, 2 insertions(+), 1 deletion(-)
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(from)
+ return to->storage == STORAGE_ENUM || type_is_integer(to)
? to_orig : NULL;
case STORAGE_F32:
case STORAGE_F64:
diff --git a/tests/26-regression.ha b/tests/26-regression.ha
@@ -119,4 +119,5 @@ 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);
};