~sircmpwn/hare-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 2

[PATCH harec] types: Fix enum castability check

Details
Message ID
<20240914172056.5063-1-yyp@disroot.org>
DKIM signature
pass
Download raw message
Patch: +3 -1
It was checking if the source is an integer, not the destination. This
made it so all integer-based enums could be cast to any type.

Reported at: https://lists.sr.ht/~sircmpwn/hare-users/%3Cd65c8dccf8f704e9fa5bf41cbca9e3dc@disroot.org%3E

Signed-off-by: Alexey Yerin <yyp@disroot.org>
---
 src/types.c            | 2 +-
 tests/26-regression.ha | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/types.c b/src/types.c
index 154acc7..1cb9b67 100644
--- a/src/types.c
+++ b/src/types.c
@@ -1052,7 +1052,7 @@ type_is_castable(struct context *ctx, const struct type *to, const struct type *
		return type_is_integer(ctx, to)
			? to_orig : NULL;
	case STORAGE_ENUM:
		return to->storage == STORAGE_ENUM || type_is_integer(ctx, from)
		return to->storage == STORAGE_ENUM || type_is_integer(ctx, to)
			? to_orig : NULL;
	case STORAGE_F32:
	case STORAGE_F64:
diff --git a/tests/26-regression.ha b/tests/26-regression.ha
index 1c8c074..b64f5fd 100644
--- a/tests/26-regression.ha
+++ b/tests/26-regression.ha
@@ -248,4 +248,6 @@ export fn main() void = {
	// as three separate tokens, rather than as a float literal
	assert(((1, 2), 3). // don't remove this comment
		0.0 == 1);

	compile(status::CHECK, "type e = enum { A }; fn f() void = { e::A: bool; };")!;
};
-- 
2.46.0

[harec/patches] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<D466I96P5H9R.3F674JE2JG61L@fra02>
In-Reply-To
<20240914172056.5063-1-yyp@disroot.org> (view parent)
DKIM signature
missing
Download raw message
harec/patches: SUCCESS in 39s

[types: Fix enum castability check][0] from [Alexey Yerin][1]

[0]: https://lists.sr.ht/~sircmpwn/hare-dev/patches/55035
[1]: yyp@disroot.org

✓ #1328032 SUCCESS harec/patches/alpine.yml  https://builds.sr.ht/~sircmpwn/job/1328032
✓ #1328033 SUCCESS harec/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/1328033
✓ #1328034 SUCCESS harec/patches/netbsd.yml  https://builds.sr.ht/~sircmpwn/job/1328034
✓ #1328035 SUCCESS harec/patches/openbsd.yml https://builds.sr.ht/~sircmpwn/job/1328035

[harec/patches] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<D466I9733B3N.2EQ2948OJF517@fra01>
In-Reply-To
<20240914172056.5063-1-yyp@disroot.org> (view parent)
DKIM signature
missing
Download raw message
harec/patches: SUCCESS in 39s

[types: Fix enum castability check][0] from [Alexey Yerin][1]

[0]: https://lists.sr.ht/~sircmpwn/hare-dev/patches/55035
[1]: yyp@disroot.org

✓ #1328032 SUCCESS harec/patches/alpine.yml  https://builds.sr.ht/~sircmpwn/job/1328032
✓ #1328033 SUCCESS harec/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/1328033
✓ #1328034 SUCCESS harec/patches/netbsd.yml  https://builds.sr.ht/~sircmpwn/job/1328034
✓ #1328035 SUCCESS harec/patches/openbsd.yml https://builds.sr.ht/~sircmpwn/job/1328035
Details
Message ID
<D466ZAXDN3GZ.3GBYXWX2DB0OV@d2evs.net>
In-Reply-To
<20240914172056.5063-1-yyp@disroot.org> (view parent)
DKIM signature
pass
Download raw message
this uncovers a bug with rune enums, which should be fixed before 
re-applying this: https://lists.sr.ht/~sircmpwn/hare-dev/patches/39048
Reply to thread Export thread (mbox)