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
Comparing two enum values with < / <= / > / >= raises TypeError in generated Python and fails to compile (E0369) in Rust #295
An ordering comparison between two values of a generated enumeration works in the C#, C, C++, Go and JavaScript output. It fails in two targets:
Python.PythonGenerator.GenerateEnumDeclaration (Coder/Languages/PythonGenerator.cs:443) writes class Colour(Enum):, and RequiredImports (L269) imports from enum import Enum. A plain enum.Enum member only supports ==/!=, so a < b raises TypeError: '<' not supported between instances of 'Colour' and 'Colour' at runtime.
A Python run test (in the style of PythonGeneratedSourceImportsTests / CallResultIntegerDivisionTests) runs before(Colour.Red, Colour.Green) and gets True.
RustGeneratedSourceCompilesTests compiles a function that compares two enum values with <.
Priority: Medium. A portable enum ordering comparison produces Python that raises TypeError at runtime and Rust that fails to compile (E0369). The other five targets are correct, and the fix in each generator is one line.
Area / suggested assignee:PythonGenerator.GenerateEnumDeclaration / RequiredImports (Enum → IntEnum) and RustGenerator.GenerateEnumDeclaration (the derive list). Owner: @matt-edmondson
Next step: switch the Python output to IntEnum and add PartialOrd, Ord to the Rust derive. Add a Python run test that checks before(Colour.Red, Colour.Green) returns True, and a Rust compile test for an enum < comparison.
Activity
matt-edmondson commentedon Oct 19, 2026
Triage
TypeErrorat runtime and Rust that fails to compile (E0369). The other five targets are correct, and the fix in each generator is one line.PythonGenerator.GenerateEnumDeclaration/RequiredImports(Enum→IntEnum) andRustGenerator.GenerateEnumDeclaration(the derive list). Owner: @matt-edmondsonPartialOrd, Ord. Either add both to Derive Clone, Copy, Debug, PartialEq, Eq and Hash on Rust enums [patch] #263 before it merges or land this fix right after it. No open PR covers the Python half. Also related: Enum member values that name other members don't compile in C, Go, Rust or JavaScript #258 (sibling references in member values), which must keep working underIntEnum.IntEnumand addPartialOrd, Ordto the Rust derive. Add a Python run test that checksbefore(Colour.Red, Colour.Green)returnsTrue, and a Rust compile test for an enum<comparison.Generated by Claude Code