]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typealias] cmd/compile: a few better comments related to alias types
authorRobert Griesemer <gri@golang.org>
Thu, 12 Jan 2017 23:21:21 +0000 (15:21 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 12 Jan 2017 23:25:54 +0000 (23:25 +0000)
For #18130.

Change-Id: I50bded3af0db673fc92b20c41a86b9cae614acd9
Reviewed-on: https://go-review.googlesource.com/35191
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/syntax.go
src/cmd/compile/internal/gc/universe.go

index 7a52dc612fbfc6d9b69072894378ad57c3d0d173..1955a0e42faaf7e543d098027059e5876c3c4092 100644 (file)
@@ -284,7 +284,7 @@ type Param struct {
        //
        // TODO: Should Func pragmas also be stored on the Name?
        Pragma Pragma
-       Alias  bool // node is alias for Ntype
+       Alias  bool // node is alias for Ntype (only used when type-checking ODCLTYPE)
 }
 
 // Func holds Node fields used only with function-like nodes.
index 30c9c3783af187cbefa9797e038f0c984691fdca..d23aebeafbb78cf23ec14fd6f94e1a53a9d0370e 100644 (file)
@@ -398,6 +398,14 @@ func lexinit1() {
        // errortype.Orig = makeErrorInterface()
        s.Def = typenod(errortype)
 
+       // We create separate byte and rune types for better error messages
+       // rather than just creating type alias *Sym's for the uint8 and
+       // int32 types. Hence, (bytetype|runtype).Sym.isAlias() is false.
+       // TODO(gri) Should we get rid of this special case (at the cost
+       // of less informative error messages involving bytes and runes)?
+       // (Alternatively, we could introduce an OTALIAS node representing
+       // type aliases, albeit at the cost of having to deal with it everywhere).
+
        // byte alias
        s = Pkglookup("byte", builtinpkg)
        bytetype = typ(TUINT8)