Skip to content

Commit

Permalink
cmd/compile: fix recursive inimport handling
Browse files Browse the repository at this point in the history
expandDecl can be called recursively, so it's not an appropriate place
to clean inimport. Instead, move this up to resolve, along with an
appropriate recursion check.

Passes toolstash-check.

Change-Id: I138d37b057dcc6525c780b4b3fbaa5e97f99655b
Reviewed-on: https://go-review.googlesource.com/120455
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
  • Loading branch information
mdempsky committed Jun 21, 2018
1 parent 6c81002 commit 011ea87
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/cmd/compile/internal/gc/iimport.go
Expand Up @@ -46,9 +46,7 @@ func expandDecl(n *Node) {
return
}

inimport = true
r.doDecl(n)
inimport = false
}

func expandInline(fn *Node) {
Expand Down
5 changes: 5 additions & 0 deletions src/cmd/compile/internal/gc/typecheck.go
Expand Up @@ -37,7 +37,12 @@ func resolve(n *Node) *Node {
}

if n.Sym.Pkg != localpkg {
if inimport {
Fatalf("recursive inimport")
}
inimport = true
expandDecl(n)
inimport = false
return n
}

Expand Down

0 comments on commit 011ea87

Please sign in to comment.