]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: Permit dereferencing of named pointer types.
authorAndrew Wilkins <axwalk@gmail.com>
Tue, 19 Feb 2013 03:03:10 +0000 (19:03 -0800)
committerRobert Griesemer <gri@golang.org>
Tue, 19 Feb 2013 03:03:10 +0000 (19:03 -0800)
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/7358044

src/pkg/go/types/expr.go
src/pkg/go/types/testdata/expr0.src

index 696a0cae684e6c70cb035a8b103dfa8f3a96724a..0caa90a1d34e2f256e6ba2775a7d1d752c1672af 100644 (file)
@@ -1193,7 +1193,7 @@ func (check *checker) rawExpr(x *operand, e ast.Expr, hint Type, iota int, cycle
                case typexpr:
                        x.typ = &Pointer{Base: x.typ}
                default:
-                       if typ, ok := x.typ.(*Pointer); ok {
+                       if typ, ok := underlying(x.typ).(*Pointer); ok {
                                x.mode = variable
                                x.typ = typ.Base
                        } else {
index c3233d36fe1b560efdc47715195c922b934fff97..8d057f63c1c415950a1430b78f062bc31b163dd8 100644 (file)
@@ -149,3 +149,13 @@ var (
        _ = &((((T{1, 2}))))
        _ = &f /* ERROR "cannot take address" */ ()
 )
+
+// recursive pointer types
+type P *P
+
+var (
+       p1 P = new(P)
+       p2 P = *p1
+       p3 P = &p2
+)
+