]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: tag builtin error, byte, rune to avoid exporting them.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Tue, 27 Aug 2013 19:18:32 +0000 (21:18 +0200)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Tue, 27 Aug 2013 19:18:32 +0000 (21:18 +0200)
Fixes #5910.
Fixes #6260.

R=golang-dev, daniel.morsing
CC=golang-dev
https://golang.org/cl/13257044

src/cmd/gc/lex.c
test/fixedbugs/bug460.dir/a.go
test/fixedbugs/bug460.dir/b.go
test/fixedbugs/issue5910.dir/a.go
test/fixedbugs/issue5910.dir/main.go

index 72094d7d84796fd6cc564c15b64130ce8dfc9ad4..ef8546638ee1ad0531900e9b67d3227c7e7ab6dc 100644 (file)
@@ -2008,27 +2008,27 @@ lexinit1(void)
        // error type
        s = lookup("error");
        s->lexical = LNAME;
-       errortype = t;
-       errortype->sym = s;
        s1 = pkglookup("error", builtinpkg);
+       errortype = t;
+       errortype->sym = s1;
        s1->lexical = LNAME;
        s1->def = typenod(errortype);
 
        // byte alias
        s = lookup("byte");
        s->lexical = LNAME;
-       bytetype = typ(TUINT8);
-       bytetype->sym = s;
        s1 = pkglookup("byte", builtinpkg);
+       bytetype = typ(TUINT8);
+       bytetype->sym = s1;
        s1->lexical = LNAME;
        s1->def = typenod(bytetype);
 
        // rune alias
        s = lookup("rune");
        s->lexical = LNAME;
-       runetype = typ(TINT32);
-       runetype->sym = s;
        s1 = pkglookup("rune", builtinpkg);
+       runetype = typ(TINT32);
+       runetype->sym = s1;
        s1->lexical = LNAME;
        s1->def = typenod(runetype);
 }
index 02a287b31777cb6230016ba48a1eb975285f6fcb..29049d9aae5779539fe0bf7c680f0a22674d6a0c 100644 (file)
@@ -6,4 +6,8 @@ package a
 
 type Foo struct {
        int
+       int8
+       error
+       rune
+       byte
 }
index 1868afe073eac07e3f1a5964a12d19580424b78e..5c0a0c47e3c164eff5ab2612663c2fb9c4f00d72 100644 (file)
@@ -9,6 +9,9 @@ import "./a"
 var x a.Foo
 
 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"
 }
-
index ea223917b6ce24a01ac94a242e3d28979de5fed7..b236c15c7d39efc6d6005cbc60e1171252de1282 100644 (file)
@@ -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
 
 type Package struct {
@@ -7,11 +11,12 @@ type Package struct {
 type Future struct {
        result chan struct {
                *Package
+               error
        }
 }
 
-func (t *Future) Result() *Package {
+func (t *Future) Result() (*Package, error) {
        result := <-t.result
        t.result <- result
-       return result.Package
+       return result.Package, result.error
 }
index 61963819515759bcde12f02a683c62471eaf0c68..c5d42ea0986e860a35836f1b9c201e3e11255608 100644 (file)
@@ -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
 
 import "a"