go
go copied to clipboard
Incorrect codecgen code is generated
Hi, I attached a sample project in order to show the issue.
The problem appears when a package tries to use code generated in other package.
To reproduce the issue follow this steps:
- Run
go mod tidy
andgo mod vendor
to download the dependencies. (vendoring is not required but used here to encapsulate the test) - Run
codecgen -nx -o test2_codec.go test2.go
in thetest2
subdirectory. - Run
codecgen -nx -o test_codec.go test.go
in the "root" directory. - Run
go test
You will get something like this:
# test.com/test
.\test_codec.go:77:11: yysf5.CodecEncodeSelf undefined (type **test2.A has no field or method CodecEncodeSelf)
.\test_codec.go:101:11: yysf7.CodecEncodeSelf undefined (type **test2.A has no field or method CodecEncodeSelf)
.\test_codec.go:227:12: yysf4.CodecEncodeSelf undefined (type **test2.A has no field or method CodecEncodeSelf)
.\test_codec.go:254:12: yysf5.CodecEncodeSelf undefined (type **test2.A has no field or method CodecEncodeSelf)
FAIL test.com/test [build failed]
I was able to patch it by replacing this line:
if ti2.flagSelfer {
with:
if ti2.flagSelfer || (isptr && ti2.flagSelferPtr) {
but not sure if the right thing to do.
Kind regards, Mauro.
Uploaded test to my github repo.
Thanks so much for catching this. Your intuition was spot on. Fixed, and it will push it soon.
Excellent. I have other fixes to tell you but give me some time to create them (because Holidays). For e.g., this the attached code
When zerocopy is active, no idea why a [32]byte
object and a type Address [32]byte
generates different flows and one of them leaves the array with zeroes.