Skip to content
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

Fix syntactic match of impl decl to definition #4709

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion toolchain/check/handle_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,15 @@ static auto PopImplIntroducerAndParamsAsNameComponent(

Parse::NodeId first_param_node_id =
context.node_stack().PopForSoloNodeId<Parse::NodeKind::ImplIntroducer>();
Parse::NodeId last_param_node_id = end_of_decl_node_id;
// Subtracting 1 since we don't want to include the final `{` or `;` of the
// declaration when performing syntactic match.
// TODO: Following proposal #3763, we should exclude any `where` clause, and
// add `Self` before `as` if needed, see:
// https://github.com/carbon-language/carbon-lang/blob/trunk/proposals/p3763.md#redeclarations
auto node_kind = context.parse_tree().node_kind(end_of_decl_node_id);
CARBON_CHECK(node_kind == Parse::NodeKind::ImplDefinitionStart ||
node_kind == Parse::NodeKind::ImplDecl);
Parse::NodeId last_param_node_id(end_of_decl_node_id.index - 1);

return {
.name_loc_id = Parse::NodeId::Invalid,
Expand Down
Loading
Loading