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
Python: an enum member whose value names a keyword-escaped sibling (Default = None) still writes the keyword, so the module fails on import #378
The #106 Python fix (45ef146) escapes a keyword-named enum member's declaration (None → None_). But PythonGenerator.GenerateEnumDeclaration (Coder/Languages/PythonGenerator.cs:490-493) writes each member's value text as given, and so does the (origin) + n that EnumMemberValues derives from it. A value that refers to an escaped sibling therefore still names the Python keyword.
Running it with python3 fails on import: TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'. Without the Next member, the import succeeds but Default is silently bound to Python's None rather than the enum member.
Expected: Default = None_ and Next = (None_) + 1.
Why it matters
None = 0 followed by Default = None is a common C# flags pattern, and the #106 commit message treats a member named None as an ordinary name. The generated module cannot be imported at all.
Not covered by open work: PR #365 (for #364) adds the same sibling-value rewrite for C++ and Rust only, and #106 tracks escaping for the other languages' declarations.
Suggested fix
Run each value through the existing helper before writing it, as the C, Go, Rust and JavaScript generators already do:
stringspelled=RenameSiblingMembers(enumDecl,value, s =>ReservedWords.Contains(s)?EscapeIdentifier(s):null);
This covers explicit values and the derived (origin) + n, because both come from the string EnumMemberValues yields.
Acceptance criteria
The repro above generates Default = None_ and Next = (None_) + 1.
A test in ReservedWordIdentifierTests runs the generated module under python3 and asserts Access.Default == Access.None_ and Access.Next == 1.
Activity