mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 10:54:49 +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:
@@ -1862,7 +1862,7 @@ static auto TryEvalInstInContext(EvalContext& eval_context,
|
||||
// argument of that specific, its constant value is the corresponding
|
||||
// argument value.
|
||||
if (auto value =
|
||||
eval_context.GetCompileTimeBindValue(bind_name.bind_index);
|
||||
eval_context.GetCompileTimeBindValue(bind_name.bind_index());
|
||||
value.has_value()) {
|
||||
return value;
|
||||
}
|
||||
@@ -1871,6 +1871,7 @@ static auto TryEvalInstInContext(EvalContext& eval_context,
|
||||
// original, with no equivalent value.
|
||||
bind.entity_name_id =
|
||||
eval_context.entity_names().MakeCanonical(bind.entity_name_id);
|
||||
// TODO: Propagate the `is_template` flag into the phase.
|
||||
return MakeConstantResult(eval_context.context(), bind, Phase::Symbolic);
|
||||
}
|
||||
case CARBON_KIND(SemIR::BindSymbolicName bind): {
|
||||
@@ -1885,10 +1886,11 @@ static auto TryEvalInstInContext(EvalContext& eval_context,
|
||||
// argument of that specific, its constant value is the corresponding
|
||||
// argument value.
|
||||
if (auto value =
|
||||
eval_context.GetCompileTimeBindValue(bind_name.bind_index);
|
||||
eval_context.GetCompileTimeBindValue(bind_name.bind_index());
|
||||
value.has_value()) {
|
||||
return value;
|
||||
}
|
||||
// TODO: Propagate the `is_template` flag into the phase.
|
||||
phase = Phase::Symbolic;
|
||||
}
|
||||
// The constant form of a symbolic binding is an idealized form of the
|
||||
|
||||
Reference in New Issue
Block a user