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

Undefined bitfield operation on enum alias #21531

Closed
TheOnlySilverClaw opened this issue May 19, 2024 · 1 comment · Fixed by #21532
Closed

Undefined bitfield operation on enum alias #21531

TheOnlySilverClaw opened this issue May 19, 2024 · 1 comment · Fixed by #21532
Assignees
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@TheOnlySilverClaw
Copy link

TheOnlySilverClaw commented May 19, 2024

Describe the bug

When I use an alias to an enum with the @[flag] attribute, I cannot use bitfield operations on the alias.

I'm not sure whether this is supposed to work, but I assumed and couldn't find documentation denying or confirming it.

Reproduction Steps

fn main() {
	
	enum_container := EnumContainer{
		et: .a | .b  // works
	}

	alias_container := AliasContainer{
		at: .a | .b  // fails
	}
}


@[flag]
enum EnumType {
	a
	b
	c
}

struct EnumContainer {
	et EnumType
}

type AliasType = EnumType

struct AliasContainer {
	at AliasType
}

Expected Behavior

The aliased type should behave like the type it aliases.
So the bitfield operations should work in both cases.

Current Behavior

Compilation fails with

flag-test.v:8:7: error: undefined operation AliasType | AliasType
6 |
7 | alias_container := AliasContainer{
8 | at: .a | .b
| ~~~~~~~
9 | }
10 | }

Possible Solution

No response

Additional Information/Context

No response

V version

0.4.5

Environment details (OS name and version, etc.)

V full version: V 0.4.5 c0afe5d.f33b712
OS: linux, Ubuntu 22.04.4 LTS

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@TheOnlySilverClaw TheOnlySilverClaw added the Bug This tag is applied to issues which reports bugs. label May 19, 2024
@Delta456
Copy link
Member

This should work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants