mirror of
https://github.com/golang/go
synced 2024-11-21 21:44:40 -07:00
gc: fix import of struct type in struct literal
Fixes #2716. R=ken2 CC=golang-dev https://golang.org/cl/5652065
This commit is contained in:
parent
53e139c7a0
commit
77aaa3555d
@ -987,7 +987,10 @@ lbrace:
|
||||
new_name:
|
||||
sym
|
||||
{
|
||||
$$ = newname($1);
|
||||
if($1 == S)
|
||||
$$ = N;
|
||||
else
|
||||
$$ = newname($1);
|
||||
}
|
||||
|
||||
dcl_name:
|
||||
@ -1418,6 +1421,19 @@ structdcl:
|
||||
{
|
||||
NodeList *l;
|
||||
|
||||
Node *n;
|
||||
if(l != nil && l->next == nil && l->n == nil) {
|
||||
// ? symbol, during import
|
||||
n = $2;
|
||||
if(n->op == OIND)
|
||||
n = n->left;
|
||||
n = embedded(n->sym);
|
||||
n->right = $2;
|
||||
n->val = $3;
|
||||
$$ = list1(n);
|
||||
break;
|
||||
}
|
||||
|
||||
for(l=$1; l; l=l->next) {
|
||||
l->n = nod(ODCLFIELD, l->n, $2);
|
||||
l->n->val = $3;
|
||||
|
File diff suppressed because it is too large
Load Diff
9
test/fixedbugs/bug415.dir/main.go
Normal file
9
test/fixedbugs/bug415.dir/main.go
Normal file
@ -0,0 +1,9 @@
|
||||
// Copyright 2012 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
import "./p"
|
||||
func main() {}
|
||||
var _ p.A
|
||||
|
14
test/fixedbugs/bug415.dir/p.go
Normal file
14
test/fixedbugs/bug415.dir/p.go
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2012 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package p
|
||||
|
||||
type A struct {
|
||||
s struct{int}
|
||||
}
|
||||
|
||||
func (a *A) f() {
|
||||
a.s = struct{int}{0}
|
||||
}
|
||||
|
9
test/fixedbugs/bug415.go
Normal file
9
test/fixedbugs/bug415.go
Normal file
@ -0,0 +1,9 @@
|
||||
// $G $D/$F.dir/p.go && $G $D/$F.dir/main.go
|
||||
|
||||
// Copyright 2012 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Issue 2716. Export metadata error made main.go not compile.
|
||||
|
||||
package ignored
|
Loading…
Reference in New Issue
Block a user