New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: go generate confounded by errors in generated code #16307
Comments
What is the exact command that you run? What is the exact error that you see? |
Note that we are likely to need a small test case in order to fix this. Unfortunate experience shows that it is very hard to recreate a specific problem from a text description. |
@monotrememan42 Do your go generate lines (the magic comments) invoke, for example, Sometimes it might help to "reset" the //go:generate echo "package foo" > parser.go
//...
//go:generate go tool yacc -o parser.go parser.y or // Start with the last known good parser.go
//go:generate git checkout -f parser.go
//...
//go:generate go tool yacc -o parser.go parser.y |
the first few lines of the source file are //go:generate nex -p Parse -e -o ../../gen/rivegen/lexer.go lexer.nex package rive i am working on getting a small reproducible example for you; i think i can do it in 2-3 files.
|
attached is a small tar file that contains a reproducible example.
|
did the attached tar file make it? i don't see it here. i'll attach it again just in case. |
i added the test case to reproduce
|
i'm not trying to annoy anyone, but i wanted to ensure someone had gotten the test cases etc. can someone please speak to that? thanks. |
With some modifications I was able to reproduce the problem. I didn't investigate more. I'd look for go/types interfering when go generate is invoked, shooting in the dark, of course. |
CL https://golang.org/cl/31659 mentions this issue. |
Please answer these questions before submitting your issue. Thanks!
go version
)?go version go1.6.2 darwin/amd64
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/andrew/code/myriad"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"
Unfortunately, this error requires multiple files to reproduce. the description should suffice, tho.
i use yacc and nex as part of a package. the generated code lives in another package
(so that generated code is not mixed in with source-controlled code).
occasionally, a mistake is made in my parse.y so that the generated parse.go causes an import cycle.
at this point, i can't simply correct parse.y (to not have the import cycle), because go generate
won't run the generate commands because (apparently) it processes the import directives first.
i observe that "go generate --help" says, in part,
Note that go generate does not parse the file, so lines that look
like directives in comments or multiline strings will be treated
as directives.
i would expect go generate to run the command and not worry about an import cycle.
go generate determines (correctly but irrelevantly) that there is an import cycle and does not run the generate commands.
The text was updated successfully, but these errors were encountered: