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
Compiler error requiring implementation of an Equals method on the derived type
Or generation of a default equals.
Or compiler error prohibiting abstract equals.
Actual behavior
Unhandled exception. System.BadImageFormatException: Bad IL format.
at DerivedRecord.Equals(DerivedRecord other)
at DerivedRecord.op_Equality(DerivedRecord left, DerivedRecord right)
at Program.<Main>$(String[] args)
Description
Record allows a
abstract bool Equals(BaseType)
method, but does not give a compiler error if it is not implemented on derived types.Reproduction Steps
On a net8.0 or net9rc2 console project:
Expected behavior
Compiler error requiring implementation of an
Equals
method on the derived typeOr generation of a default equals.
Or compiler error prohibiting abstract equals.
Actual behavior
Regression?
I don't think so.
❌ net6.0-windows
❌ net7.0-windows
❌ net8.0-windows
❌ net9rc2-linux
Known Workarounds
Remove the abstract equals, or implement equals on all derived types:
Configuration
.Net 8.0.403 on W11 23H2 (22631) on x64
AnyCPU, x86, and x64 all produce same results
Other information
No response
The text was updated successfully, but these errors were encountered: