aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/gofix/typecheck.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/gofix/typecheck.go')
-rw-r--r--src/cmd/gofix/typecheck.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cmd/gofix/typecheck.go b/src/cmd/gofix/typecheck.go
index 23fc8bfe96..a6c7eac634 100644
--- a/src/cmd/gofix/typecheck.go
+++ b/src/cmd/gofix/typecheck.go
@@ -138,6 +138,7 @@ func typecheck(cfg *TypeConfig, f *ast.File) (typeof map[interface{}]string, ass
assign = make(map[string][]interface{})
cfg1 := &TypeConfig{}
*cfg1 = *cfg // make copy so we can add locally
+ copied := false
// gather function declarations
for _, decl := range f.Decls {
@@ -185,7 +186,8 @@ func typecheck(cfg *TypeConfig, f *ast.File) (typeof map[interface{}]string, ass
if cfg1.Type[s.Name.Name] != nil {
break
}
- if cfg1.Type == cfg.Type || cfg1.Type == nil {
+ if !copied {
+ copied = true
// Copy map lazily: it's time.
cfg1.Type = make(map[string]*Type)
for k, v := range cfg.Type {