Skip to content

transpile: Translate enums in switch as their own type instead of integers - #1817

Draft
Rua wants to merge 14 commits into
immunant:masterfrom
Rua:match-enum
Draft

transpile: Translate enums in switch as their own type instead of integers#1817
Rua wants to merge 14 commits into
immunant:masterfrom
Rua:match-enum

Conversation

@Rua

@Rua Rua commented May 21, 2026

Copy link
Copy Markdown
Contributor

Enum constant names are now preserved in match arms where present, which significantly improves code fidelity.

@ahomescu ahomescu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This needs a rebase, but CI should pass now.

@Rua
Rua force-pushed the match-enum branch 4 times, most recently from 84cf432 to eb10415 Compare August 6, 2026 20:04
@ahomescu

ahomescu commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

I think there might be one codegen bug here: for this C code

enum Bar { BarN1 = -1, Bar0, Bar1 };   // integral type: int
void f(int x) { enum Bar b = x; }

the transpiled Rust code fails to compile. Let me know if you reproduce it.

@Rua
Rua force-pushed the match-enum branch 2 times, most recently from a896bfd to fd1a4f7 Compare August 7, 2026 08:16
@Rua

Rua commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Yeah I could reproduce it. Fixed now, I hope.

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.

case statements do not preserve enum constants

2 participants