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:
Richard Smith
2025-02-13 02:15:22 +00:00
committed by GitHub
parent f502e8d6ff
commit 6dda094928
32 changed files with 705 additions and 165 deletions
+1 -1
View File
@@ -444,6 +444,7 @@ class NodeStack {
case Parse::NodeKind::StructLiteralStart:
case Parse::NodeKind::StructTypeLiteralField:
case Parse::NodeKind::StructTypeLiteralStart:
case Parse::NodeKind::TemplateBindingName:
case Parse::NodeKind::TupleLiteralStart:
case Parse::NodeKind::TuplePatternStart:
case Parse::NodeKind::VariableInitializer:
@@ -508,7 +509,6 @@ class NodeStack {
case Parse::NodeKind::StructLiteralComma:
case Parse::NodeKind::StructFieldDesignator:
case Parse::NodeKind::StructTypeLiteralComma:
case Parse::NodeKind::Template:
case Parse::NodeKind::TupleLiteralComma:
return Id::Kind::Invalid;
default: