]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1] cmd/gc: fix PkgPath of byte, rune types
authorRuss Cox <rsc@golang.org>
Fri, 21 Sep 2012 19:54:58 +0000 (05:54 +1000)
committerRuss Cox <rsc@golang.org>
Fri, 21 Sep 2012 19:54:58 +0000 (05:54 +1000)
««« backport 272e1dd72156
cmd/gc: fix PkgPath of byte, rune types

Fixes #3853.

R=ken2
CC=golang-dev
https://golang.org/cl/6492071

»»»

src/cmd/gc/reflect.c
src/pkg/reflect/all_test.go

index f77697a6b8d185ddabefa05c31f0b776f4359be1..39f65981990d799506c4591316c8bd229314c125 100644 (file)
@@ -672,6 +672,12 @@ dtypesym(Type *t)
        Sig *a, *m;
        Type *t1, *tbase, *t2;
 
+       // Replace byte, rune aliases with real type.
+       // They've been separate internally to make error messages
+       // better, but we have to merge them in the reflect tables.
+       if(t == bytetype || t == runetype)
+               t = types[t->etype];
+
        if(isideal(t))
                fatal("dtypesym %T", t);
 
index e331405635a7f5d4ab6724f1079fbae67fe7cd83..a0b9a03eb5469bd6394ef719024ec80a9b21a5e5 100644 (file)
@@ -1384,7 +1384,30 @@ func TestImportPath(t *testing.T) {
                path string
        }{
                {TypeOf(&base64.Encoding{}).Elem(), "encoding/base64"},
+               {TypeOf(int(0)), ""},
+               {TypeOf(int8(0)), ""},
+               {TypeOf(int16(0)), ""},
+               {TypeOf(int32(0)), ""},
+               {TypeOf(int64(0)), ""},
                {TypeOf(uint(0)), ""},
+               {TypeOf(uint8(0)), ""},
+               {TypeOf(uint16(0)), ""},
+               {TypeOf(uint32(0)), ""},
+               {TypeOf(uint64(0)), ""},
+               {TypeOf(uintptr(0)), ""},
+               {TypeOf(float32(0)), ""},
+               {TypeOf(float64(0)), ""},
+               {TypeOf(complex64(0)), ""},
+               {TypeOf(complex128(0)), ""},
+               {TypeOf(byte(0)), ""},
+               {TypeOf(rune(0)), ""},
+               {TypeOf([]byte(nil)), ""},
+               {TypeOf([]rune(nil)), ""},
+               {TypeOf(string("")), ""},
+               {TypeOf((*interface{})(nil)).Elem(), ""},
+               {TypeOf((*byte)(nil)), ""},
+               {TypeOf((*rune)(nil)), ""},
+               {TypeOf((*int64)(nil)), ""},
                {TypeOf(map[string]int{}), ""},
                {TypeOf((*error)(nil)).Elem(), ""},
        }