Skip to content

cmd/vet: know what builtin functions have no side effects #22851

Description

@mvdan

Reminder issue to continue the work in https://go-review.googlesource.com/c/go/+/79536.

For example, len and cap never have any side effects, and it would be useful to know that i == len(x) || i == len(x) is a suspicious expression.

More broadly, this could be extended to automatically detect what functions are free of side effects. But this would require having access to the full source with full type information, and may be complex and costly, so I'm not entirely sure it's a right fit for vet.

A simpler version of the above would be to also add standard library functions, such as strings.Contains or path.Join. I don't know if it is OK for vet to treat standard library packages differently, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AnalysisIssues related to static analysis (vet, x/tools/go/analysis)NeedsFixThe path to resolution is known, but the work has not been done.help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions