]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/vet: don't complain about Error()
authorShenghou Ma <minux.ma@gmail.com>
Thu, 17 Jan 2013 18:24:12 +0000 (02:24 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Thu, 17 Jan 2013 18:24:12 +0000 (02:24 +0800)
Fixes #4598.

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/7102050

src/cmd/vet/print.go

index cda5fcd7c8e08c200de83e350f161256b4fc1f6e..a402d3de41788924ccdca4ae3ebe6f206b8fcdaa 100644 (file)
@@ -253,7 +253,8 @@ func (f *File) checkPrint(call *ast.CallExpr, name string, skip int) {
                }
        }
        if len(args) <= skip {
-               if *verbose && !isLn {
+               // TODO: check that the receiver of Error() is of type error.
+               if !isLn && name != "Error" {
                        f.Badf(call.Pos(), "no args in %s call", name)
                }
                return
@@ -299,6 +300,8 @@ func BadFunctionUsedInTests() {
        f.Warnf(0, "%s", "hello", 3) // ERROR "wrong number of args in Warnf call"
        f.Warnf(0, "%r", "hello")    // ERROR "unrecognized printf verb"
        f.Warnf(0, "%#s", "hello")   // ERROR "unrecognized printf flag"
+       var e error
+       fmt.Println(e.Error()) // correct, used to trigger "no args in Error call"
 }
 
 // printf is used by the test.