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.
pull/6/head
Tim Hockin 2016-06-24 21:07:17 +09:00
parent 96c0284e91
commit ab16ccc158
1 changed files with 6 additions and 0 deletions

View File

@ -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