Skip to content

Comparing two enum values with < / <= / > / >= raises TypeError in generated Python and fails to compile (E0369) in Rust #295

Closed

Description

@matt-edmondson

What's wrong

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:

Reproduction (portable AST)

The SourceFile contains:

  • EnumDeclaration("Colour") with members Red and Green.
  • bool before(Colour a, Colour b) { return a < b; }, written as BinaryOperator.LessThan over two VariableReferences.

Results:

  • Python: before(Colour.Red, Colour.Green) raises TypeError (checked with python3).
  • Rust: rustc --crate-type lib gives E0369.
  • C, C++ (enum class), C#, Go (type Colour int) and JavaScript (frozen numbers): all compare by the underlying value, as expected.

Suggested fix

Acceptance criteria

  • 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 <.
  • The Rust half lands after, or together with, Derive Clone, Copy, Debug, PartialEq, Eq and Hash on Rust enums [patch] #263, since it changes the same derive line.

Activity

  1. added
    bug
    on Oct 19, 2026
  2. matt-edmondson commented on Oct 19, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions