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
go/build: MultiplePackageError values swapped. #9409
Comments
Nice find. We should have a vet rule detect all unkeyed literals when the struct has any two fields with the same type. /cc @adonovan |
That sounds like a good idea. For posterity, this issue was introduced in commit 4f80b50. |
Perhaps we should also consider the case when field value in a literal is assignable to more than one field. This is a much larger set. For example: type T struct { uint; int; float64 } |
About two seconds after I wrote my comment I knew somebody would point that out. Yes, @alandonovan, assignable. :-) |
Huh. Apparently github doesn't send emails from linked issues. Anyway, I filed #9421 to track this proposed vet rule. |
Sent https://go-review.googlesource.com/2040 for this bug. |
This issue is present in the latest commit on
master
branch, f34964e.MultiplePackageError
is defined in src/go/build/build.go#L420-L426 withDir
, thenPackages
, and finallyFiles
:It is used in the following incorrect way in src/go/build/build.go#L690-L692:
If one rewrites that composite literal to use keyed fields, the mistake becomes obvious:
Notably, the last 2 parameter values should be swapped.
The text was updated successfully, but these errors were encountered: