~sircmpwn/hare-dev

harec: gen: fix assertion failure when using uintptr enums in globals v2 APPLIED

Alexey Yerin: 1
 gen: fix assertion failure when using uintptr enums in globals

 2 files changed, 8 insertions(+), 0 deletions(-)
#787146 alpine.yml success
#787147 freebsd.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/hare-dev/patches/33258/mbox | git am -3
Learn more about email & git

[PATCH harec v2] gen: fix assertion failure when using uintptr enums in globals Export this patch

Signed-off-by: Alexey Yerin <yyp@disroot.org>
---
v1 -> v2: Add a test

Is this correct?

 src/gen.c         | 1 +
 tests/15-enums.ha | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/src/gen.c b/src/gen.c
index d26e43e..38bfe90 100644
--- a/src/gen.c
+++ b/src/gen.c
@@ -3544,6 +3544,7 @@ gen_data_item(struct gen_context *ctx, struct expression *expr,
		case STORAGE_U64:
		case STORAGE_I64:
		case STORAGE_SIZE:
		case STORAGE_UINTPTR:
			item->type = QD_VALUE;
			item->value = constl((uint64_t)constant->uval);
			break;
diff --git a/tests/15-enums.ha b/tests/15-enums.ha
index 8238ac0..27c6965 100644
--- a/tests/15-enums.ha
+++ b/tests/15-enums.ha
@@ -46,6 +46,13 @@ type rune_storage = enum rune {
	BAR = '1',
};

type uintptr_storage = enum uintptr {
	FOO = 0,
	BAR = 1,
};

let global_uintptr: uintptr_storage = uintptr_storage::FOO;

fn storage() void = {
	assert(size(explicit_values) == size(int));
	assert(size(with_storage) == 2);
-- 
2.36.1
harec/patches: SUCCESS in 52s

[gen: fix assertion failure when using uintptr enums in globals][0] v2 from [Alexey Yerin][1]

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

✓ #787146 SUCCESS harec/patches/alpine.yml  https://builds.sr.ht/~sircmpwn/job/787146
✓ #787147 SUCCESS harec/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/787147
Pushed with a note about non-64bit platforms. Thanks!

To git@git.sr.ht:~turminal/dotfiles
   04ae538..8c88587  master -> master