Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/vet: know what builtin functions have no side effects #22851
Reminder issue to continue the work in https://go-review.googlesource.com/c/go/+/79536.
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
That was the intention with the existing code, but it was buggy; builtin functions aren't treated as values by types.TypeAndVal. Thus, we should use the IsBuiltin method instead of IsValue. Teaching vet what builtin funcs are pure is already being tracked as a separate issue, #22851. While at it, also add a test with methods, just to be sure that the current logic doesn't break with that edge case either. Fixes #25303. Change-Id: Ic18402b22cceeabf76641c02f575b194b9a536cc Reviewed-on: https://go-review.googlesource.com/112177 Run-TryBot: Daniel Martí <email@example.com> Run-TryBot: Robert Griesemer <firstname.lastname@example.org> TryBot-Result: Gobot Gobot <email@example.com> Reviewed-by: Robert Griesemer <firstname.lastname@example.org>