Skip to content

proposal: cmd/vet: relax "composites" check to module scope #43864

Open
@muirdm

Description

@muirdm

I propose we relax the "composites" vet check to allow implicit field name use if the struct literal and struct type are within the same module.

Currently the "composites" vet check allows implicit struct field names if the struct type and struct literal are in the same package. When adding a new struct field you can certainly update uses in the same package and avoid errors. Now that modules provide a formal grouping of packages we can further relax the "composites" check to allow implicit field use within the same module because you similarly can update all struct uses throughout the module when adding a new struct field.

This came up when discussing whether gopls should suppress implicit field completions that would fail vet.

To implement this change the analyzer would need to be able to map a types.Package to a module name. I don't know exactly how this would work.

/cc @mvdan

Metadata

Metadata

Assignees

No one assigned

    Labels

    AnalysisIssues related to static analysis (vet, x/tools/go/analysis)Proposal

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions