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

Comptime @[flag] enum evaluation is wrong #19925

Closed
lemoncmd opened this issue Nov 18, 2023 · 3 comments · Fixed by #19939
Closed

Comptime @[flag] enum evaluation is wrong #19925

lemoncmd opened this issue Nov 18, 2023 · 3 comments · Fixed by #19939
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Unit: Checker Bugs/feature requests, that are related to the type checker.

Comments

@lemoncmd
Copy link
Contributor

lemoncmd commented Nov 18, 2023

Describe the bug

when you declare const enum variable with @[flag], the result of comptime evaluation is wrong.
the behavior changes if you omit the enum name.

Reproduction Steps

>>> @[flag]enum Foo{a b c}
>>> const aa = Foo.a
>>> aa
Foo{}
>>> const ab = Foo.a | Foo.b
>>> ab
Foo{.a}
>>> const ac = Foo.a | Foo.b | Foo.c
>>> ac
Foo{.a | .b}
>>> const ad = Foo.a | .b | .c
>>> ad
Foo{}
>>> const ae = Foo.a | .b | .c
>>> ae
Foo{}
>>> const af = Foo.a | .b | Foo.c
>>> af
Foo{.b}
>>>

Expected Behavior

>>> @[flag]enum Foo{a b c}
>>> const aa = Foo.a
>>> aa
Foo{.a}
>>> const ab = Foo.a | Foo.b
>>> ab
Foo{.a | .b}
>>> const ac = Foo.a | Foo.b | Foo.c
>>> ac
Foo{.a | .b | .c}
>>> const ad = Foo.a | .b | .c
>>> ad
Foo{.a | .b | .c}
>>> const ae = Foo.a | .b | .c
>>> ae
Foo{.a | .b | .c}
>>> const af = Foo.a | .b | Foo.c
>>> af
Foo{.a | .b | .c}
>>>

Current Behavior

see above

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.3 8c8df9e

Environment details (OS name and version, etc.)

OS: Arch linux

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.

@lemoncmd lemoncmd added the Bug This tag is applied to issues which reports bugs. label Nov 18, 2023
@felipensp felipensp self-assigned this Nov 19, 2023
@felipensp felipensp added the Unit: Checker Bugs/feature requests, that are related to the type checker. label Nov 19, 2023
@lemoncmd
Copy link
Contributor Author

Anon enum evaluation is not fixed.

>>> @[flag]enum Foo{a b c}
>>> const aa = Foo.a | Foo.b | Foo.c
>>> aa
Foo{.a | .b | .c}
>>> const ab = Foo.a | .b | .c
>>> ab
Foo{.a}

@felipensp
Copy link
Member

Anon enum evaluation is not fixed.

>>> @[flag]enum Foo{a b c}
>>> const aa = Foo.a | Foo.b | Foo.c
>>> aa
Foo{.a | .b | .c}
>>> const ab = Foo.a | .b | .c
>>> ab
Foo{.a}

Thanks, I'll submit a PR fixing right now.

@spytheman
Copy link
Member

@lemoncmd can you please check again with latest V?

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. Unit: Checker Bugs/feature requests, that are related to the type checker.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants