From 3d20bbe0fb2f6c3c3b340ce4d0bbcd1ad880071c Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Mon, 31 Jul 2023 11:15:33 -0400 Subject: [PATCH] internal/gcimporter: add a missing return if objectpath fails The export data encoding was not symmetric in the case where objectpath fails. Fixes golang/go#61670 Change-Id: Ifaaa8eaed7ee5e28aa3b5ee7e9600b9e379e1968 Reviewed-on: https://go-review.googlesource.com/c/tools/+/514355 gopls-CI: kokoro TryBot-Result: Gopher Robot Reviewed-by: Hyang-Ah Hana Kim Run-TryBot: Robert Findley --- internal/gcimporter/iexport.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/gcimporter/iexport.go b/internal/gcimporter/iexport.go index 3e3fce1731f..da2fa7a1bb9 100644 --- a/internal/gcimporter/iexport.go +++ b/internal/gcimporter/iexport.go @@ -929,10 +929,11 @@ func (w *exportWriter) objectPath(obj types.Object) { // that export/import is producing a correct package. // // TODO: remove reportf once we have such confidence. - objectPath = "" + w.string("") if w.p.reportf != nil { w.p.reportf("unable to encode object %q in package %q: %v", obj.Name(), obj.Pkg().Path(), err) } + return } w.string(string(objectPath)) w.pkg(obj.Pkg())