mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Reject/error on base declarations that appear after field declarations (#4553)
Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
parent
16bf3f710e
commit
ffbcfc4dfc
@@ -512,6 +512,15 @@ auto HandleParseNode(Context& context, Parse::BaseDeclId node_id) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!context.struct_type_fields_stack().PeekArray().empty()) {
|
||||
// TODO: Add note that includes the first field location as an example.
|
||||
CARBON_DIAGNOSTIC(
|
||||
BaseDeclAfterFieldDecl, Error,
|
||||
"`base` declaration must appear before field declarations");
|
||||
context.emitter().Emit(node_id, BaseDeclAfterFieldDecl);
|
||||
return true;
|
||||
}
|
||||
|
||||
auto base_info = CheckBaseType(context, base_type_node_id, base_type_expr_id);
|
||||
|
||||
// The `base` value in the class scope has an unbound element type. Instance
|
||||
|
||||
Reference in New Issue
Block a user