From: Matthew Dempsky Date: Thu, 21 Jun 2018 22:35:32 +0000 (-0700) Subject: cmd/compile: fix recursive inimport handling X-Git-Tag: go1.11beta1~33 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=011ea87921cb37dc8e4147d99c22234f875d2651;p=gostls13.git cmd/compile: fix recursive inimport handling 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 TryBot-Result: Gobot Gobot Reviewed-by: Robert Griesemer --- diff --git a/src/cmd/compile/internal/gc/iimport.go b/src/cmd/compile/internal/gc/iimport.go index d158899aaa..54c5d8dc2f 100644 --- a/src/cmd/compile/internal/gc/iimport.go +++ b/src/cmd/compile/internal/gc/iimport.go @@ -46,9 +46,7 @@ func expandDecl(n *Node) { return } - inimport = true r.doDecl(n) - inimport = false } func expandInline(fn *Node) { diff --git a/src/cmd/compile/internal/gc/typecheck.go b/src/cmd/compile/internal/gc/typecheck.go index 8f0d6050c3..1b68e057fc 100644 --- a/src/cmd/compile/internal/gc/typecheck.go +++ b/src/cmd/compile/internal/gc/typecheck.go @@ -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 }