]> Cypherpunks.ru repositories - gostls13.git/commitdiff
gc: remove type elision in struct literals
authorRuss Cox <rsc@golang.org>
Mon, 5 Dec 2011 19:22:41 +0000 (14:22 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 5 Dec 2011 19:22:41 +0000 (14:22 -0500)
R=ken2
CC=golang-dev
https://golang.org/cl/5437136

src/cmd/gc/typecheck.c
test/complit.go
test/complit1.go

index 802d6dcdc538787c785102ec6fb379dd0ada86e6..eb6e84e63e5715b21edb45f846e2e36eac211795 100644 (file)
@@ -2183,7 +2183,7 @@ typecheckcomplit(Node **np)
                                s = f->sym;
                                fielddup(newname(s), hash, nhash);
                                r = l->right;
-                               pushtype(r, f->type);
+                               // No pushtype allowed here.  Tried and rejected.
                                typecheck(&r, Erv);
                                l->right = assignconv(r, f->type, "field value");
                        }
index c9de616f5541dc4d4b4d9db25b728c73b5361390..8dfc71dcb47ab5bc138585f039d66aa453461be4 100644 (file)
@@ -58,7 +58,7 @@ func main() {
        var tp *T
        tp = &T{0, 7.2, "hi", &t}
 
-       tl := &T{i: 0, next: {i: 1, next: {i: 2, next: {i: 3, next: {i: 4}}}}}
+       tl := &T{i: 0, next: &T{i: 1, next: &T{i: 2, next: &T{i: 3, next: &T{i: 4}}}}}
        teq(tl, 5)
 
        a1 := []int{1, 2, 3}
index f4f7311af3dbbb0d4df604ca082b58a593c61653..aaf701f73f7153ee3212ebb43ab8617713bfd084 100644 (file)
@@ -34,6 +34,6 @@ type T struct {
 
 var (
        _ = &T{0, 0, "", nil}               // ok
-       _ = &T{i: 0, f: 0, s: "", next: {}} // ok
+       _ = &T{i: 0, f: 0, s: "", next: {}} // ERROR "missing type in composite literal"
        _ = &T{0, 0, "", {}}                // ERROR "missing type in composite literal"
 )