You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The root cause appears to be function-summary escape data appearing within a function type where it is not expected.
Compilation of this file
package burnin
type sendCmdFunc func(string)
func sendCommand(c string) {}
func NewSomething() {
// This works...
// var sendCmd sendCmdFunc
// sendCmd = sendCommand
// This fails...
sendCmd := sendCommand
_ = sendCmd
}
creates export data that won't parse. The syntax error "unexpected string literal" is attributed to the importing line. For example, building this file will yield such an error:
package main
import (
x "./burnin" // Syntax error is attributed to this line.
)
func main() {
x.NewSomething()
}
Comparing the export data from the "This works" variant to the one that fails, it appears that escape data attached to an in-line (as opposed to named) function type causes the problem:
ianlancetaylor
changed the title
Bad export data causes "unexpected string literal" on import.
cmd/compile: bad export data causes "unexpected string literal" on import
Dec 30, 2015
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>
The root cause appears to be function-summary escape data appearing within a function type where it is not expected.
Compilation of this file
creates export data that won't parse. The syntax error "unexpected string literal" is attributed to the importing line. For example, building this file will yield such an error:
Comparing the export data from the "This works" variant to the one that fails, it appears that escape data attached to an in-line (as opposed to named) function type causes the problem:
The text was updated successfully, but these errors were encountered: