You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rust: an enum member that aliases another (Default = Low, or any repeated value) fails to compile with E0081 "discriminant value assigned more than once" #388
C#, C, C++, Go, Python (as an alias) and JS all allow two enum members with the same value. Default = Low and All = Read are common C# idioms, and #378 already treats Default = None as valid input.
Since #258, RustGenerator.GenerateEnumDeclaration rewrites a sibling reference as Name::Sibling as i32 and writes it as a discriminant:
E0081: discriminant value 16 assigned more than once (A/E)
E0081: discriminant value 17 assigned more than once (B/F)
The g++, gcc, go build, python3 and node outputs for the same input all build and run.
Suggested fix / acceptance criteria
Write a member whose value repeats an earlier member's value as an associated constant instead of a variant: impl Bits { #[allow(non_upper_case_globals)] pub const E: Bits = Bits::A; }
A value that is exactly a sibling's name is the minimum case. Implicit successors after an alias need the same treatment, so F becomes pub const F: Bits = Bits::B.
A Rust compile test covering Level { Low, Mid, High, Default = Low } and the Bits enum above, asserting Bits::E as i32 == 16 and Bits::F as i32 == 17.
Category: Bug. Rust output does not compile (E0081) when an enum member aliases another member or an implicit successor lands on an existing value.
Priority: Medium. Aliases such as Default = Low and All = Read are common C# idioms, and every other target already handles them. The failure is a compile error, not silently wrong output. The fix is contained to the enum path.
Activity
matt-edmondson commentedon Oct 30, 2026
Triage
Default = LowandAll = Readare common C# idioms, and every other target already handles them. The failure is a compile error, not silently wrong output. The fix is contained to the enum path.Coder/Languages/RustGenerator.csGenerateEnumDeclaration, the sibling-reference rewrite from Enum member values that name other members don't compile in C, Go, Rust or JavaScript #258. Tests go inRustGeneratedSourceCompilesTests.Default = None) still writes the keyword, so the module fails on import #378 treatsDefault = Noneas valid input. Escape keyword-named enum members in C++ and Rust [patch] #365 (open PR, escaping keyword-named enum members in C++/Rust) touches the same method, so a merge conflict is possible.Generated by Claude Code