mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: print struct tags in var decl in inlined func body
This bug was introduced in golang.org/cl/18217, while trying to fix #13777. Originally I wanted to just disable inlining for the case being handled incorrectly, but it's fairly difficult to detect and much easier just to fix. Since the case being handled incorrectly was inlined correctly in Go 1.5, not inlining it would also be somewhat of a regression. So just fix it. Test case copied from Ian's CL 19520. The mistake to worry about in this CL would be relaxing the condition too much (we now print the note more often than we did yesterday). To confirm that we'd catch this mistake, I checked that changing (!fmtbody || !t.Funarg) to (true) does cause fixedbugs/issue13777.go to fail. And putting it back to what is written in this CL makes that test pass again as well as the new fixedbugs/issue14331.go. So I believe that the new condition is correct for both constraints. Fixes #14331. Change-Id: I91f75a4d5d07c53af5caea1855c780d9874b8df6 Reviewed-on: https://go-review.googlesource.com/19514 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
e136cac48c
commit
feb2a5d610
4 changed files with 41 additions and 1 deletions
|
|
@ -748,7 +748,13 @@ func typefmt(t *Type, flag int) string {
|
|||
if name != "" {
|
||||
str = name + " " + typ
|
||||
}
|
||||
if flag&obj.FmtShort == 0 && !fmtbody && t.Note != nil {
|
||||
|
||||
// The fmtbody flag is intended to suppress escape analysis annotations
|
||||
// when printing a function type used in a function body.
|
||||
// (The escape analysis tags do not apply to func vars.)
|
||||
// But it must not suppress struct field tags.
|
||||
// See golang.org/issue/13777 and golang.org/issue/14331.
|
||||
if flag&obj.FmtShort == 0 && (!fmtbody || !t.Funarg) && t.Note != nil {
|
||||
str += " " + strconv.Quote(*t.Note)
|
||||
}
|
||||
return str
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue