-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Records won't warn about an unimplemented abstract ToString #76554
Comments
Why should this be an error? The compiler synthesizes ToString for all records, right? So the method will be implemented. |
I'd interpret abstract to mean "must be user provided in source", so a compiler-generated method shouldn't satisfy that. |
Abstract means an override must be provided. The compiler provides that override. It has nothing to do with the user providing it or not :-) |
And that's specified by the CIL. There's a lot of things that metadata doesn't care about but the language does. Like out/ref for example. I think this could be adjacent to that, only if you agree that it should be possible to reabstract record members that are inherited from object. |
I don't know what you're asking for here. You said you thought this was a bug. I'm saying that i don't think this is a bug in the compiler, and the compiler is doing exactly the right thing as far as the language is concerned. At no point in the design of records did we say that if the base method is abstract that you would then have an error if the user didn't implement the method in source themselves. If you want that, you'd need to propose a language change over at csharplang. |
Version Used: 98ea496
Steps to Reproduce:
Expected Behavior:
error CS0534: 'RecordBase.Record' does not implement inherited abstract member 'RecordBase.ToString()'
Actual Behavior: there's no error on the record declaration.
The text was updated successfully, but these errors were encountered: