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
A record that declares operator == doesn't compile in C# (CS0111) or Rust (E0119) because the record already supplies equality #301
A ClassDeclaration { IsRecord = true } with a member FunctionDeclaration("==") { Kind = FunctionKind.Operator } generates output that doesn't compile in two targets.
error CS0111: Type 'Point' already defines a member called 'op_Equality' with the same parameter types
the same error for op_Inequality
Declaring only != fails the same way, because the partner logic then adds ==.
Rust: the record gets #[derive(Clone, Debug, PartialEq)] (Coder/Languages/RustGenerator.cs around L591-595), and the declared == becomes impl PartialEq for Point { fn eq ... } (the operator-trait mapping around L229 and L813). The result is error[E0119]: conflicting implementations of trait 'PartialEq' for type 'Point'.
Reproduction
Build this AST: a record Point with an int x field and bool operator ==(Point rhs) returning true. Generate C# and Rust, then compile the output with dotnet build and rustc. You get the errors above. The same AST without IsRecord compiles in both targets.
Suggested fix
C#: when a record declares == or !=, don't emit the operator itself and don't run MissingComparisonPartners for ==/!=. Either write the user's equality as public virtual bool Equals(Point? other) (records let you override that), or write the inexpressible note.
Rust: leave PartialEq out of the record's derive list when the type declares == (or !=), so the user's impl PartialEq is the only one.
Acceptance criteria
C# and Rust compile tests (*GeneratedSourceCompilesTests) cover:
a record that declares ==
a record that declares only !=
Records that don't declare equality operators keep their current output.
Priority: Low. The output is a compile error rather than silently wrong code, and only for a narrow shape: a record that also declares ==/!=, which is redundant in both C# and Rust.
Area / suggested assignee:MissingComparisonPartners in Coder/Languages/CSharpGenerator.cs (~L321), and the record derive in Coder/Languages/RustGenerator.cs (~L591-595, ~L229, ~L813). Owner: @matt-edmondson
Next step: for records, skip emitting ==/!= and their partner in C# (or map them to Equals(T?)), drop PartialEq from the Rust derive when the type declares ==, and add the two compile-test cases.
Activity
matt-edmondson commentedon Oct 19, 2026
Triage
==/!=, which is redundant in both C# and Rust.MissingComparisonPartnersinCoder/Languages/CSharpGenerator.cs(~L321), and the record derive inCoder/Languages/RustGenerator.cs(~L591-595,~L229,~L813). Owner: @matt-edmondson==/!=and their partner in C# (or map them toEquals(T?)), dropPartialEqfrom the Rust derive when the type declares==, and add the two compile-test cases.Generated by Claude Code