From a96c2b8c1afd8fbf7a16ed2f4e5f647c5f8cc17a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 1 Sep 2012 19:55:55 -0400 Subject: [PATCH] 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 | 6 ++++++ src/pkg/reflect/all_test.go | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/cmd/gc/reflect.c b/src/cmd/gc/reflect.c index f4c235a480..7496b71bf2 100644 --- a/src/cmd/gc/reflect.c +++ b/src/cmd/gc/reflect.c @@ -680,6 +680,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); diff --git a/src/pkg/reflect/all_test.go b/src/pkg/reflect/all_test.go index 3b6fd5e585..148db888a7 100644 --- a/src/pkg/reflect/all_test.go +++ b/src/pkg/reflect/all_test.go @@ -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(), ""}, }