From bd7c626348f3013ef307f9e3ae7c51708e2579eb Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 29 May 2012 13:15:13 -0700 Subject: [PATCH] exp/types: properly read dotted identifiers Fixes #3682. R=rsc CC=golang-dev https://golang.org/cl/6256067 --- src/pkg/exp/types/gcimporter.go | 2 +- src/pkg/exp/types/gcimporter_test.go | 7 ------- src/pkg/exp/types/testdata/exports.go | 5 +++++ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/pkg/exp/types/gcimporter.go b/src/pkg/exp/types/gcimporter.go index af1eef804a..f584c39091 100644 --- a/src/pkg/exp/types/gcimporter.go +++ b/src/pkg/exp/types/gcimporter.go @@ -182,7 +182,7 @@ func (p *gcParser) init(filename, id string, src io.Reader, imports map[string]* func (p *gcParser) next() { p.tok = p.scanner.Scan() switch p.tok { - case scanner.Ident, scanner.Int, scanner.String: + case scanner.Ident, scanner.Int, scanner.String, '·': p.lit = p.scanner.TokenText() default: p.lit = "" diff --git a/src/pkg/exp/types/gcimporter_test.go b/src/pkg/exp/types/gcimporter_test.go index c39b47b062..20247b0dc4 100644 --- a/src/pkg/exp/types/gcimporter_test.go +++ b/src/pkg/exp/types/gcimporter_test.go @@ -92,13 +92,6 @@ func testDir(t *testing.T, dir string, endTime time.Time) (nimports int) { } func TestGcImport(t *testing.T) { - // Dies trying to read crypto/md5, which contains - // const init1 = 0x... - // The importer believes init1 should be a function for some reason. - // golang.org/issue/3682. - t.Logf("broken; skipping") - return - // On cross-compile builds, the path will not exist. // Need to use GOHOSTOS, which is not available. if _, err := os.Stat(gcPath); err != nil { diff --git a/src/pkg/exp/types/testdata/exports.go b/src/pkg/exp/types/testdata/exports.go index ed63bf9ade..8ee28b0942 100644 --- a/src/pkg/exp/types/testdata/exports.go +++ b/src/pkg/exp/types/testdata/exports.go @@ -11,6 +11,11 @@ import ( "go/ast" ) +// Issue 3682: Correctly read dotted identifiers from export data. +const init1 = 0 + +func init() {} + const ( C0 int = 0 C1 = 3.14159265 -- 2.48.1