aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/vet/testdata
diff options
context:
space:
mode:
authorDaniel Martí <mvdan@mvdan.cc>2018-05-04 14:39:00 +0700
committerRobert Griesemer <gri@golang.org>2018-05-07 16:41:00 +0000
commit3fbfc83db298c55669b6165eca1b8a56b04c895c (patch)
treefc5869fdbceb628c8f0ea422492ede5b4250a77e /src/cmd/vet/testdata
parentd474f582fed7c9b6bc78deee3d09f77b4c8af9ad (diff)
downloadgo-3fbfc83db298c55669b6165eca1b8a56b04c895c.tar.xz
cmd/vet: recognise func type conversions
In hasSideEffects, vet has to be taught whether or not a CallExpr is an actual function call, or just a type conversion. The previous code knew how to differentiate fn(arg) from int(arg), but it incorrectly saw (func(T))(fn) as a func call. This edge case is slightly tricky, since the CallExpr.Fun has a func signature type, just like in func calls. However, the difference is that in this case the Fun is a type, not a value. This information is in types.TypeAndValue, so use it. Change-Id: I18bb8b23abbe7decc558b726ff2dc31fae2f13d6 Reviewed-on: https://go-review.googlesource.com/111416 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/cmd/vet/testdata')
-rw-r--r--src/cmd/vet/testdata/bool.go3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/cmd/vet/testdata/bool.go b/src/cmd/vet/testdata/bool.go
index bada13ae0d..be78caac18 100644
--- a/src/cmd/vet/testdata/bool.go
+++ b/src/cmd/vet/testdata/bool.go
@@ -24,8 +24,7 @@ func RatherStupidConditions() {
_ = i == T(2) || i == T(2) // ERROR "redundant or: i == T(2) || i == T(2)"
_ = FT(f) == nil || FT(f) == nil // ERROR "redundant or: FT(f) == nil || FT(f) == nil"
- // TODO: distinguish from an actual func call
- _ = (func() int)(f) == nil || (func() int)(f) == nil
+ _ = (func() int)(f) == nil || (func() int)(f) == nil // ERROR "redundant or: (func() int)(f) == nil || (func() int)(f) == nil"
var namedFuncVar FT
_ = namedFuncVar() == namedFuncVar() // OK; still func calls