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

Bug: discriminant is marked as collided when using ranged alternatives with default or catch_all attributes. #144

Open
AlexSherbinin opened this issue Mar 10, 2024 · 1 comment · May be fixed by #145

Comments

@AlexSherbinin
Copy link

I have tried this code:

#[derive(FromPrimitive)]
#[repr(u8)]
enum Number {
    Zero = 0,
    #[num_enum(alternatives = [2..=3])]
    OneTwoThree = 1,
    #[num_enum(catch_all)]
    Other(u8)
}

And got following error:

error: The discriminant '2' collides with a value attributed to a previous variant
   |
15 |     Other(u8)
   |     ^^^^^

When there is no collision between Other and OneTwoThree variant

AlexSherbinin added a commit to AlexSherbinin/num_enum that referenced this issue Mar 10, 2024
@AlexSherbinin AlexSherbinin linked a pull request Mar 10, 2024 that will close this issue
AlexSherbinin added a commit to AlexSherbinin/num_enum that referenced this issue Mar 10, 2024
@AlexSherbinin
Copy link
Author

Noticed that it's ok for default variants to emit this error because with this attribute it's allowed to have a discriminant. Anyway it stays catch_all only bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant