Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

bugfix(derive) implicit discriminants were wrongly calculated - #11

Open
nduchaux wants to merge 2 commits into
amsam0:trunkfrom
nduchaux:trunk
Open

bugfix(derive) implicit discriminants were wrongly calculated#11
nduchaux wants to merge 2 commits into
amsam0:trunkfrom
nduchaux:trunk

Conversation

@nduchaux

Copy link
Copy Markdown

When a enum variant had no explicit discriminant, there was a try to calculate it by looking at the previous one.
This was not working at all:

  • the first enum variant was never looked at
  • when finding an enum variant with a discriminant, it was taking its value + 1 (even if it was not the immediate previous one).

This commit corrects the logic to make it work.

@nduchaux

Copy link
Copy Markdown
Author

The second commit permits to "parse" any numeric literals (e.g. 0x1234). This was not the case for the first one (or even before that).
For simplifity, I had to add a dependancy to eval the result from the base discriminant with the "offset".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant