Skip to content

Support automatic value assignment to Enum members #1134

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

Merged
merged 6 commits into from
Sep 23, 2022

Conversation

czgdp1807
Copy link
Collaborator

No description provided.

@czgdp1807 czgdp1807 marked this pull request as ready for review September 22, 2022 10:14
@czgdp1807 czgdp1807 requested a review from certik September 22, 2022 10:14
d: i32 = 0
e: i32 = auto()
f: i32 = 7
g: i32 = auto()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python does not have the best syntax here, but since this is what they do, we'll do it too for now. We can later fix this to something like:

@enum
class Color:
    RED: i32
    GREEN: i32
    BLUE: i32 = 7
    YELLOW: i32
    WHITE: i32
    PINK: i32 = 15
    GREY: i32

which seems nicer.

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is fine.

@czgdp1807 czgdp1807 enabled auto-merge September 23, 2022 05:02
@czgdp1807 czgdp1807 merged commit c6626b4 into lcompilers:main Sep 23, 2022
@czgdp1807 czgdp1807 deleted the enum03 branch September 23, 2022 05:52
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 this pull request may close these issues.

2 participants