From ab16ccc1582862ad750add5ecfa085daaa52d0b1 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Fri, 24 Jun 2016 21:07:17 +0900 Subject: [PATCH] go2idl: don't mutate a map being iterated This was causing us to process packages we didn't really want, which was only visible when debugging was enabled. --- cmd/libs/go2idl/parser/parse.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/libs/go2idl/parser/parse.go b/cmd/libs/go2idl/parser/parse.go index 6496dc04c84..331bfc92f45 100644 --- a/cmd/libs/go2idl/parser/parse.go +++ b/cmd/libs/go2idl/parser/parse.go @@ -337,7 +337,13 @@ func (b *Builder) typeCheckPackage(id string) (*tc.Package, error) { func (b *Builder) makePackages() error { b.pkgs = map[string]*tc.Package{} + + // Take a snapshot to iterate, since this will recursively mutate b.parsed. + keys := []string{} for id := range b.parsed { + keys = append(keys, id) + } + for _, id := range keys { // We have to check here even though we made a new one above, // because typeCheckPackage follows the import graph, which may // cause a package to be filled before we get to it in this