mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Superficial support for template modifier on symbolic bindings. (#4948)
Change parse tree from `template (T:! type)` to `(template T):! type`, so that we have information about whether a binding is a template binding available when forming the representation of the binding pattern. This incidentally fixes a bug that we would accept `template addr A:! B` instead of the intended `addr template A:! B`. Track whether a symbolic binding is a template binding on the `EntityName` object. I'm borrowing a bit from the `CompileTimeBindIndex` for this in order to avoid making `EntityName`s larger. Longer-term, we should think about using a different representation for symbolic bindings, to avoid including these fields in all `EntityName`s, but that's out of scope for this change. So far, template bindings are treated as having the same phase as checked bindings, but that will change in a future PR.
This commit is contained in:
@@ -169,10 +169,10 @@ auto HandleParseNode(Context& context,
|
||||
// We model `Self` as a symbolic binding whose type is the interface.
|
||||
// Because there is no equivalent non-symbolic value, we use `None` as
|
||||
// the `value_id` on the `BindSymbolicName`.
|
||||
auto entity_name_id = context.entity_names().Add(
|
||||
{.name_id = SemIR::NameId::SelfType,
|
||||
.parent_scope_id = interface_info.scope_id,
|
||||
.bind_index = context.scope_stack().AddCompileTimeBinding()});
|
||||
auto entity_name_id = context.entity_names().AddSymbolicBindingName(
|
||||
SemIR::NameId::SelfType, interface_info.scope_id,
|
||||
context.scope_stack().AddCompileTimeBinding(),
|
||||
/*is_template=*/false);
|
||||
interface_info.self_param_id =
|
||||
context.AddInst(SemIR::LocIdAndInst::NoLoc<SemIR::BindSymbolicName>(
|
||||
{.type_id = self_type_id,
|
||||
|
||||
Reference in New Issue
Block a user