Skip to content

Commit 95835d8

Browse files
authored
Set brackets on TypeList in parser (#448)
Add a setter for brackets on `TypeList` and set them in the parser.
1 parent 8408f3f commit 95835d8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

experimental/ast/type_generic.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ func (d TypeList) Brackets() token.Token {
126126
return d.raw.brackets.In(d.Context())
127127
}
128128

129+
// SetBrackets sets the token tree for the brackets wrapping the argument list.
130+
func (d TypeList) SetBrackets(brackets token.Token) {
131+
d.Context().Nodes().panicIfNotOurs(brackets)
132+
d.raw.brackets = brackets.ID()
133+
}
134+
129135
// Len implements [seq.Indexer].
130136
func (d TypeList) Len() int {
131137
if d.IsZero() {
@@ -140,7 +146,7 @@ func (d TypeList) At(n int) TypeAny {
140146
return newTypeAny(d.Context(), d.raw.args[n].Value)
141147
}
142148

143-
// At implements [seq.Setter].
149+
// SetAt implements [seq.Setter].
144150
func (d TypeList) SetAt(n int, ty TypeAny) {
145151
d.Context().Nodes().panicIfNotOurs(ty)
146152
d.raw.args[n].Value = ty.raw

experimental/parser/parse_decl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ func parseRange(p *parser, c *token.Cursor) ast.DeclRange {
371371

372372
// parseTypeList parses a type list out of a bracket token.
373373
func parseTypeList(p *parser, parens token.Token, types ast.TypeList, in taxa.Noun) {
374+
types.SetBrackets(parens)
374375
delimited[ast.TypeAny]{
375376
p: p,
376377
c: parens.Children(),

0 commit comments

Comments
 (0)