-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Diagnose var
in interfaces
#4907
Conversation
Previously this was ignored, and then carbon-language#4720 accidentally made it a crash bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
@@ -386,6 +386,12 @@ auto HandleParseNode(Context& context, Parse::VariableDeclId node_id) -> bool { | |||
} | |||
return true; | |||
} | |||
if (context.GetCurrentScopeAs<SemIR::InterfaceDecl>()) { | |||
CARBON_DIAGNOSTIC(VarInInterfaceDecl, Error, | |||
"interfaces cannot have `var` members"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The style guide wants to say what occurred, rather than what cannot occur: https://github.com/carbon-language/carbon-lang/blob/40f3de2c0726983c7c41200eddd479ceec00be5e/toolchain/docs/diagnostics.md#diagnostic-message-style-guide
Maybe "var
binding found in interface
"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I wasn't thinking about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM too, thanks
Previously this was ignored, and then #4720 accidentally made it a crash bug