@@ -337,6 +337,20 @@ type (
337337 Dir ChanDir // channel direction
338338 Value Expr // value type
339339 }
340+
341+ // A TupleType node represents a tuple type.
342+ // Tuple types are syntactic sugar for anonymous structs with ordinal field names.
343+ // Examples:
344+ // () ≡ struct{}
345+ // (T) ≡ T (degenerates to the type itself)
346+ // (T0, T1, ..., TN) ≡ struct{ _0 T0; _1 T1; ...; _N TN }
347+ // (name0 T0, name1 T1, ..., nameN TN) ≡ struct{ _0 T0; _1 T1; ...; _N TN }
348+ // Named fields are compile-time aliases only; runtime uses ordinal fields.
349+ TupleType struct {
350+ Lparen token.Pos // position of "("
351+ Fields * FieldList // tuple element types (and optional names)
352+ Rparen token.Pos // position of ")"
353+ }
340354)
341355
342356// Pos and End implementations for expression/type nodes.
@@ -414,6 +428,9 @@ func (x *MapType) Pos() token.Pos { return x.Map }
414428// Pos returns position of first character belonging to the node.
415429func (x * ChanType ) Pos () token.Pos { return x .Begin }
416430
431+ // Pos returns position of first character belonging to the node.
432+ func (x * TupleType ) Pos () token.Pos { return x .Lparen }
433+
417434// End returns position of first character immediately after the node.
418435func (x * BadExpr ) End () token.Pos { return x .To }
419436
@@ -498,6 +515,9 @@ func (x *MapType) End() token.Pos { return x.Value.End() }
498515// End returns position of first character immediately after the node.
499516func (x * ChanType ) End () token.Pos { return x .Value .End () }
500517
518+ // End returns position of first character immediately after the node.
519+ func (x * TupleType ) End () token.Pos { return x .Rparen + 1 }
520+
501521// exprNode() ensures that only expression/type nodes can be
502522// assigned to an Expr.
503523func (* BadExpr ) exprNode () {}
@@ -522,6 +542,7 @@ func (*FuncType) exprNode() {}
522542func (* InterfaceType ) exprNode () {}
523543func (* MapType ) exprNode () {}
524544func (* ChanType ) exprNode () {}
545+ func (* TupleType ) exprNode () {}
525546
526547// ----------------------------------------------------------------------------
527548// Convenience functions for Idents
0 commit comments