Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/vet: incorrect "redundant invocation" report #6148

Closed
fsouza opened this issue Aug 14, 2013 · 3 comments

Comments

Projects
None yet
4 participants
@fsouza
Copy link
Contributor

commented Aug 14, 2013

% cat abc.go
package main

import (
    "fmt"
)

type Person struct {
    name string
}

func (p *Person) String() string {
    return p.name
}

func main() {
    p := Person{name: "Gopher"}
    fmt.Printf("%s\n", p.String())
}
% go vet abc.go
abc.go:17: redundant invocation of String method of p

It's not redundant, because String method requires a pointer receiver. So, *Person
implements the Stringer interface, but Person does not.

Following vet advice produces the wrong result: http://play.golang.org/p/CnXisy9MC_.
@robpike

This comment has been minimized.

Copy link
Contributor

commented Aug 15, 2013

Comment 1:

I vote for just reverting the CL that added this. It's not a problem to be explicit
about those methods even when they are unnecessary.

Labels changed: added priority-soon, removed priority-triage, go1.2maybe.

Owner changed to @dsymonds.

Status changed to Accepted.

@dsymonds

This comment has been minimized.

Copy link
Member

commented Aug 15, 2013

Comment 2:

Yeah, I have also tripped over this. It could use the typechecker a little more to work
out whether p has the method on that type, but maybe this is just overstepping govet's
purview.
Give me a day to think about it.
@dsymonds

This comment has been minimized.

Copy link
Member

commented Aug 19, 2013

Comment 3:

This issue was closed by revision golang/tools@a7c698b.

Status changed to Fixed.

@fsouza fsouza added fixed labels Aug 19, 2013

@golang golang locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.