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
Enum member values that name other members don't compile in C, Go, Rust or JavaScript #258
The docs for EnumMember.Value (Coder/Ast/EnumMember.cs:28-36) say a value may be "a literal, another member, an expression over them". The C, Go, Rust and JavaScript generators copy the value text verbatim, but they rename or scope the members it refers to. The generated reference then points at a name that doesn't exist.
Reproduction
Use enum Perm with members Read = 1, Write = 2, ReadWrite = "Read | Write" and Next (no value), generated inside a SourceFile. Each output below was checked with the real compiler or runtime.
Language
Generated
Result
C
Perm_ReadWrite = Read | Write (CGenerator.cs:990-997; members renamed by SpellEnumMember at :1018-1022)
gcc: 'Read' undeclared
Go
PermReadWrite Perm = Read | Write (GoGenerator.cs:1503-1515; Prefixed renames constants, not the value)
Priority: Medium. The form EnumMember.Value documents (a value that refers to another member) breaks the C, Go and Rust compiles and makes the JavaScript throw on load. It only affects enums whose values reference siblings, and C#, C++ and Python are correct.
Area / suggested assignee: the enum-member value writers in CGenerator, GoGenerator, RustGenerator and JavaScriptGenerator (LanguageGeneratorBase.EnumMemberValues). Owner: @matt-edmondson
Next step: rewrite whole-word sibling references in the value using the generator's own member spelling. For JavaScript, substitute the values EnumMemberValues already computes. Add the Perm enum to the compile tests.
Activity
matt-edmondson commentedon Oct 18, 2026
Triage
EnumMember.Valuedocuments (a value that refers to another member) breaks the C, Go and Rust compiles and makes the JavaScript throw on load. It only affects enums whose values reference siblings, and C#, C++ and Python are correct.CGenerator,GoGenerator,RustGeneratorandJavaScriptGenerator(LanguageGeneratorBase.EnumMemberValues). Owner: @matt-edmondsonfn type(...)(Rust) /int default()(C++) that fails to compile #106 (identifiers emitted verbatim), but the cause is separate: the generator renames a member and the value text doesn't follow the rename.EnumMemberValuesalready computes. Add thePermenum to the compile tests.Generated by Claude Code