checkassign(n->left);
typecheck(&n->right, Erv);
- if(n->left->type != T && n->right && n->right->type != T)
- n->right = typecheckconv(nil, n->right, n->left->type, 0, nil);
+ if(n->right && n->right->type != T) {
+ if(n->left->type != T)
+ n->right = typecheckconv(nil, n->right, n->left->type, 0, "assignment");
+ else
+ exportassignok(n->right->type, "assignment");
+ }
if(n->left->defn == n && n->left->ntype == N) {
defaultlit(&n->right, T);
n->left->type = n->right->type;
x := sync.Mutex{key: 0}; // ERROR "(unknown|assignment).*Mutex"
_ = x;
}
+ {
+ x := &sync.Mutex{}; // ok
+ var y sync.Mutex; // ok
+ y = *x; // ERROR "assignment.*Mutex"
+ *x = y; // ERROR "assignment.*Mutex"
+ _ = x;
+ _ = y;
+ }
}
--- /dev/null
+// Copyright 2009 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 x
+
+type T struct { x, Y int }
+
+func (t T) M()
--- /dev/null
+// Copyright 2009 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 y
+
+import "./x"
+
+func f() {
+ ok := new(x.T);
+ var ok1 x.T;
+ ok2 := &ok1;
+ ok3 := &x.T{};
+ ok4 := &x.T{Y:2};
+ _ = x.T{};
+ _ = x.T{Y:2};
+
+ ok1.M(); // ERROR "assignment.*T"
+ bad1 := *ok; // ERROR "assignment.*T"
+ bad2 := ok1; // ERROR "assignment.*T"
+ *ok4 = ok1; // ERROR "assignment.*T"
+ *ok4 = *ok2; // ERROR "assignment.*T"
+ ok1 = *ok4; // ERROR "assignment.*T"
+ _ = bad1;
+ _ = bad2;
+ _ = ok4;
+ _ = ok3;
+ _ = ok2;
+ _ = ok1;
+ _ = ok;
+}
--- /dev/null
+// $G $D/$F.dir/x.go && errchk $G $D/$F.dir/y.go
+
+// Copyright 2009 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.
+
+ignored