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

go/types: types are not collected for go or defer statement call expressions. #6413

Closed
kisielk opened this issue Sep 17, 2013 · 3 comments
Closed
Assignees

Comments

@kisielk
Copy link
Contributor

@kisielk kisielk commented Sep 17, 2013

What steps will reproduce the problem?

    fset := token.NewFileSet()
    src := `
package p

func f() int {
    return 1
}

func g() {
    defer f()
    go f()
}
`
    f, err := parser.ParseFile(fset, "", src, 0)
    if err != nil {
        t.Fatal(err)
    }

    var conf Config
    types := make(map[ast.Expr]Type)
    _, err = conf.Check(f.Name.Name, fset, []*ast.File{f}, &Info{Types: types})
    if err != nil {
        t.Error(err)
    }

    for x, typ := range types {
        if exp, ok := x.(*ast.CallExpr); ok {
            fmt.Printf("%+v, %v\n", exp, typ)
        }
    }

What is the expected output?
Two lines of output, one for the call expression corresponding to `defer f()` and one
for `go f()`.

What do you see instead?
No output.

Which version are you using?  (run 'go version')
go version devel +2e735aa41d4a Tue Sep 17 13:30:36 2013 -0400 darwin/amd64

I'm trying to use this functionality for my program errcheck
(github.com/kisielk/errcheck) to check if someone ignored an error return by calling `go
f()` or `defer f()` where f() is a function that returns an error type.
@robpike
Copy link
Contributor

@robpike robpike commented Sep 18, 2013

Comment 1:

Labels changed: added priority-soon, removed priority-triage.

Owner changed to @griesemer.

Status changed to Accepted.

Loading

@griesemer
Copy link
Contributor

@griesemer griesemer commented Sep 24, 2013

Comment 2:

This was fixed with rev a4c389d37f20.

Loading

@griesemer
Copy link
Contributor

@griesemer griesemer commented Sep 24, 2013

Comment 3:

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

Status changed to Fixed.

Loading

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants