mirror of
https://github.com/golang/go
synced 2024-11-25 07:07:57 -07:00
gc: remove type elision in struct literals
R=ken2 CC=golang-dev https://golang.org/cl/5437136
This commit is contained in:
parent
98553f1422
commit
5cb1c82d96
@ -2183,7 +2183,7 @@ typecheckcomplit(Node **np)
|
|||||||
s = f->sym;
|
s = f->sym;
|
||||||
fielddup(newname(s), hash, nhash);
|
fielddup(newname(s), hash, nhash);
|
||||||
r = l->right;
|
r = l->right;
|
||||||
pushtype(r, f->type);
|
// No pushtype allowed here. Tried and rejected.
|
||||||
typecheck(&r, Erv);
|
typecheck(&r, Erv);
|
||||||
l->right = assignconv(r, f->type, "field value");
|
l->right = assignconv(r, f->type, "field value");
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ func main() {
|
|||||||
var tp *T
|
var tp *T
|
||||||
tp = &T{0, 7.2, "hi", &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)
|
teq(tl, 5)
|
||||||
|
|
||||||
a1 := []int{1, 2, 3}
|
a1 := []int{1, 2, 3}
|
||||||
|
@ -34,6 +34,6 @@ type T struct {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
_ = &T{0, 0, "", nil} // ok
|
_ = &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"
|
_ = &T{0, 0, "", {}} // ERROR "missing type in composite literal"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user