Make an ast.TypeExpr's ID0 field more consistent

This commit is contained in:
Nigel Tao committed 2018-04-20 16:21:16 +10:00
1 parent 90a794c0b8
commit 4ddc2f0055
5 files changed
+11 -11

No files matched your search

+4 -4
View File
@@ -618,7 +618,7 @@ const MaxTypeExprDepth = 63
// TypeExpr is a type expression, such as "base.u32", "base.u32[..8]", "foo",
// "pkg.bar", "ptr T", "array[8] T" or "slice T":
// - ID0: <0|IDPtr|IDArray|IDSlice|IDOpenParen>
// - ID0: <0|IDPtr|IDArray|IDSlice|IDFunc>
// - ID1: <0|pkg>
// - ID2: <0|type name>
// - LHS: <nil|Expr>
@@ -631,9 +631,9 @@ const MaxTypeExprDepth = 63
//
// An IDSlice ID0 means "slice RHS". RHS is the inner type.
//
// An IDOpenParen ID0 means "LHS.ID2", a function or method type. LHS is the
// receiver type, which may be nil. If non-nil, it will be a pointee type: "T"
// instead of "ptr T", "ptr ptr T", etc.
// An IDFunc ID0 means "func ID2" or "func (LHS).ID2", a function or method
// type. LHS is the receiver type, which may be nil. If non-nil, it will be a
// pointee type: "T" instead of "ptr T", "ptr ptr T", etc.
//
// TODO: method effects: "foo" vs "foo!" vs "foo?".
//
+1 -1
View File
@@ -223,7 +223,7 @@ func (n *TypeExpr) appendStr(buf []byte, tm *t.Map, depth uint32) []byte {
case t.IDSlice:
buf = append(buf, "slice "...)
return n.Inner().appendStr(buf, tm, depth)
case t.IDOpenParen:
case t.IDFunc:
buf = append(buf, "func "...)
if r := n.Receiver(); r != nil {
buf = append(buf, '(')