Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support using enum constants as array index #144

Closed
bvdberg opened this issue Dec 31, 2024 · 2 comments
Closed

support using enum constants as array index #144

bvdberg opened this issue Dec 31, 2024 · 2 comments

Comments

@bvdberg
Copy link
Member

bvdberg commented Dec 31, 2024

i32[] array = {
.color.Red = ..,
.color.Green = ..,
}

currently not possible

@SchokiCoder
Copy link
Contributor

Hello again,
I might be confusing something, but it looks like it does work.
This currently compiles and runs:

module test;

import stdio;

type Color enum i32 {
	Red,
	Green,
	Blue,
}

public fn i32 main()
{
	char[] arr = {
		[Color.Red] = 'R',
		[Color.Green] = 'G',
		[Color.Blue] = 'B',
	}

	stdio.printf("hello world %c\n", arr[Color.Blue]);

	return 0;
}

Am I missing something?

@bvdberg
Copy link
Member Author

bvdberg commented Feb 1, 2025

Yes it is indeed fixed! I'll close this issue :)

@bvdberg bvdberg closed this as completed Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants