Skip to content
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/vet: flag unkeyed struct literals when a struct has two fields of the same type #9421

Open
josharian opened this issue Dec 22, 2014 · 1 comment
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis)
Milestone

Comments

@josharian
Copy link
Contributor

Suggested in #9409.

Note that vet already flags all unkeyed composite struct literals when the type comes from a different package. This would extend checks to same-package types, but with more stringent criteria.

@bradfitz @alandonovan @shurcooL

@bradfitz
Copy link
Contributor

From @alandonovan in the other thread:

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 }
var _ = T{0, 1, 2}

@mikioh mikioh changed the title tools/cmd/vet: flag unkeyed struct literals when a struct has two fields of the same type cmd/vet: flag unkeyed struct literals when a struct has two fields of the same type Jan 4, 2015
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc changed the title cmd/vet: flag unkeyed struct literals when a struct has two fields of the same type x/tools/cmd/vet: flag unkeyed struct literals when a struct has two fields of the same type Apr 14, 2015
@rsc rsc modified the milestones: Unreleased, Unplanned Apr 14, 2015
@rsc rsc removed the repo-tools label Apr 14, 2015
@mvdan mvdan changed the title x/tools/cmd/vet: flag unkeyed struct literals when a struct has two fields of the same type cmd/vet: flag unkeyed struct literals when a struct has two fields of the same type May 31, 2018
@adonovan adonovan added the Analysis Issues related to static analysis (vet, x/tools/go/analysis) label Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis)
Projects
None yet
Development

No branches or pull requests

4 participants