fatal("typeinit: %s already defined", s->name);
t = typ(etype);
- t->sym = s;
+ t->sym = s1;
dowidth(t);
types[etype] = t;
*utfrune(name, CenterDot) = 0;
}
- if(exportname(name) || s->pkg == builtinpkg) // old behaviour, tests pass, but is it correct?
+ if(exportname(name))
n = newname(lookup(name));
else
n = newname(pkglookup(name, s->pkg));
t = l->n->left->type->type;
if(t->sym == S)
t = t->type;
- fmtprint(f, " %T:%N", t, l->n->right);
+ fmtprint(f, " %hhS:%N", t->sym, l->n->right);
} else
fmtprint(f, " %hhS:%N", l->n->left->sym, l->n->right);
if(etype != Txxx) {
if(etype < 0 || etype >= nelem(types))
fatal("lexinit: %s bad etype", s->name);
+ s1 = pkglookup(syms[i].name, builtinpkg);
t = types[etype];
if(t == T) {
t = typ(etype);
- t->sym = s;
+ t->sym = s1;
if(etype != TANY && etype != TSTRING)
dowidth(t);
types[etype] = t;
}
- s1 = pkglookup(syms[i].name, builtinpkg);
s1->lexical = LNAME;
s1->def = typenod(t);
continue;
ot = dgopkgpath(s, ot, t1->sym->pkg);
} else {
ot = dgostringptr(s, ot, nil);
- ot = dgostringptr(s, ot, nil);
+ if(t1->type->sym != S && t1->type->sym->pkg == builtinpkg)
+ ot = dgopkgpath(s, ot, localpkg);
+ else
+ ot = dgostringptr(s, ot, nil);
}
ot = dsymptr(s, ot, dtypesym(t1->type), 0);
ot = dgostrlitptr(s, ot, t1->note);
--- /dev/null
+// 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 a
+
+type Foo struct {
+ int
+}
--- /dev/null
+// 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 b
+
+import "./a"
+
+var x a.Foo
+
+func main() {
+ x.int = 20 // ERROR "unexported field"
+}
+
--- /dev/null
+// errorcheckdir
+
+// 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.
+
+// part one of issue 4124. Make sure that the compiler rejects access attempts.
+
+package ignored
+
--- /dev/null
+// run
+
+// 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.
+
+// part two of issue 4124. Make sure reflect doesn't mark the field as exported.
+
+package main
+
+import "reflect"
+
+var T struct {
+ int
+}
+
+func main() {
+ v := reflect.ValueOf(&T)
+ v = v.Elem().Field(0)
+ if v.CanSet() {
+ panic("int should be unexported")
+ }
+}