-
Notifications
You must be signed in to change notification settings - Fork 286
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
Different results when removing the GOCACHE and pkgs directories #680
Comments
Same with Go 1.17.8 |
OK i think i have a reproducer now at least for the reported problem. It does disappear when one includes all code in one file. |
go.mod
model/mode.go
valid/valid.go
Doing Revive on this code:
But when valid/valid.go is merging everything into one file:
There is no problem anymore:
|
Narrowed this down to ".TypeCheck()" throwing an error which is mostly never checked in the repository. The error is something like So the reason for throwing that error is that the type information is not present? My guess is that the type information is loaded from the binary-files which makes it clearer why deleting the GOCACHE/pkgs directories lead to a reported problem. If that is true, two things need fixing(?)
|
This issue may seem to also affect us. In CI we are running both If we run |
@zimmski the root cause is that How do you think about this solution? @mgechev @chavacava |
Sounds great, looking forward to your fix :-) Ping me when i should test it with our CI. |
Type information of each package is calculated lazily. The calculation relies on the GO's |
Yes, but I found that it still didn't work after loading the package first, need do more investigations on this issue. |
EDIT: Disregard. In my case the nondeterminism was caused by my not using the
|
This issue should can be fixed after #716 since it'll load all packages. |
Cool, can do many checks after this PR since we have enough type infos. I'm wondering if we can introduce go/packages when try to fix this issue because this will break many test cases. Anyway, I like this change, also can have a hand on fixing those testdata if you need. |
Yes, type info allows to implement some fancy checks but nothing is free... type info calculation takes time.
Thanks! At some point I will ask for help on fixing some things like testcases. |
Describe the bug
This is more of a "i need a better idea on how to debug this" bug reports because i do have a reproducer, but it involves our monorepo (which i can't just send out).
The bug of this issue is that the output of revive is not deterministic for one specific problem. The following Revive config enables the rule that finds the reported problem.
Which leads to the following problem in the reproducer i am currently reducing:
tt.go:20:15: suspicious assignment of 'p'. range-loop variables always have the same address
The problem appears deterministically in our CI but it does not appear locally on my machine right away. I need to do some steps to reproduce it but then it is again deterministically reporting the problem.
First i thought it is a race, but when i compile Revive with the race detector on, there is no race anymore with the latest changes. So i ran out of ideas on what the problem is.
One idea i had was that this must have something to do with how packages are loaded to resolve types because i reduce the code down to:
"model" is an import identifier. When i copy the types directly into the same file as the reduce code, Revive does not report a problem anymore.
Expected behavior
I would expected to always have the same problem.
Desktop:
The text was updated successfully, but these errors were encountered: