mirror of
https://github.com/golang/go
synced 2024-11-25 01:27:56 -07:00
cmd/gc: tag builtin error, byte, rune to avoid exporting them.
Fixes #5910. Fixes #6260. R=golang-dev, daniel.morsing CC=golang-dev https://golang.org/cl/13257044
This commit is contained in:
parent
4fc7ff497d
commit
a85cfbd433
@ -2008,27 +2008,27 @@ lexinit1(void)
|
|||||||
// error type
|
// error type
|
||||||
s = lookup("error");
|
s = lookup("error");
|
||||||
s->lexical = LNAME;
|
s->lexical = LNAME;
|
||||||
errortype = t;
|
|
||||||
errortype->sym = s;
|
|
||||||
s1 = pkglookup("error", builtinpkg);
|
s1 = pkglookup("error", builtinpkg);
|
||||||
|
errortype = t;
|
||||||
|
errortype->sym = s1;
|
||||||
s1->lexical = LNAME;
|
s1->lexical = LNAME;
|
||||||
s1->def = typenod(errortype);
|
s1->def = typenod(errortype);
|
||||||
|
|
||||||
// byte alias
|
// byte alias
|
||||||
s = lookup("byte");
|
s = lookup("byte");
|
||||||
s->lexical = LNAME;
|
s->lexical = LNAME;
|
||||||
bytetype = typ(TUINT8);
|
|
||||||
bytetype->sym = s;
|
|
||||||
s1 = pkglookup("byte", builtinpkg);
|
s1 = pkglookup("byte", builtinpkg);
|
||||||
|
bytetype = typ(TUINT8);
|
||||||
|
bytetype->sym = s1;
|
||||||
s1->lexical = LNAME;
|
s1->lexical = LNAME;
|
||||||
s1->def = typenod(bytetype);
|
s1->def = typenod(bytetype);
|
||||||
|
|
||||||
// rune alias
|
// rune alias
|
||||||
s = lookup("rune");
|
s = lookup("rune");
|
||||||
s->lexical = LNAME;
|
s->lexical = LNAME;
|
||||||
runetype = typ(TINT32);
|
|
||||||
runetype->sym = s;
|
|
||||||
s1 = pkglookup("rune", builtinpkg);
|
s1 = pkglookup("rune", builtinpkg);
|
||||||
|
runetype = typ(TINT32);
|
||||||
|
runetype->sym = s1;
|
||||||
s1->lexical = LNAME;
|
s1->lexical = LNAME;
|
||||||
s1->def = typenod(runetype);
|
s1->def = typenod(runetype);
|
||||||
}
|
}
|
||||||
|
@ -6,4 +6,8 @@ package a
|
|||||||
|
|
||||||
type Foo struct {
|
type Foo struct {
|
||||||
int
|
int
|
||||||
|
int8
|
||||||
|
error
|
||||||
|
rune
|
||||||
|
byte
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,8 @@ var x a.Foo
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
x.int = 20 // ERROR "unexported field"
|
x.int = 20 // ERROR "unexported field"
|
||||||
|
x.int8 = 20 // ERROR "unexported field"
|
||||||
|
x.error = nil // ERROR "unexported field"
|
||||||
|
x.rune = 'a' // ERROR "unexported field"
|
||||||
|
x.byte = 20 // ERROR "unexported field"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2013 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
|
package a
|
||||||
|
|
||||||
type Package struct {
|
type Package struct {
|
||||||
@ -7,11 +11,12 @@ type Package struct {
|
|||||||
type Future struct {
|
type Future struct {
|
||||||
result chan struct {
|
result chan struct {
|
||||||
*Package
|
*Package
|
||||||
|
error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Future) Result() *Package {
|
func (t *Future) Result() (*Package, error) {
|
||||||
result := <-t.result
|
result := <-t.result
|
||||||
t.result <- result
|
t.result <- result
|
||||||
return result.Package
|
return result.Package, result.error
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2013 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
|
package main
|
||||||
|
|
||||||
import "a"
|
import "a"
|
||||||
|
Loading…
Reference in New Issue
Block a user