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/go: go test does not show all parser errors #3055

Closed
dvyukov opened this issue Feb 17, 2012 · 5 comments
Closed

cmd/go: go test does not show all parser errors #3055

dvyukov opened this issue Feb 17, 2012 · 5 comments
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented Feb 17, 2012

For the following code:

func ExampleCond_single() {
    var m Mutex
    c := MakeCond(&m)
    percent := 0
    const step = 10
    for i := 0; i < 5; i++ {
        go func() {       // ######## LINE 134
            for {
                // Emulates some useful work.
                time.Sleep(1e8)
                m.Lock()
                defer    // ######## The problem is actually here
                if percent == 100 {
                    m.Unlock()
                    break
                }
                percent++
                if percent % step == 0 {
                    c.Signal()
                }
                m.Unlock()
            }
        }()
    }
    for {
        m.Lock()
        if percent == 0 || percent % step != 0 {
            c.Wait()
        }
        fmt.Print(",")
        if percent == 100 {
            m.Unlock()
            break
        }
        m.Unlock()
    }
}

gc says only:
cond_test.go:134:6: expected function/method call (and 14 more errors)

This usually means then I miss "()" after "go func() {}", but it is
not the case here. It confuses. The problem is actually with stand-alone defer.

12079:45a0ca092e9d tip
@rsc
Copy link
Contributor

rsc commented Feb 17, 2012

Comment 1:

What command were you running?
That's not gc talking, or the :6: would
not be there.  It's some program using
go/parser and not expanding the error list.
The part about defer is surely one of the
14 more errors.

Status changed to WaitingForReply.

@dvyukov
Copy link
Member Author

dvyukov commented Feb 17, 2012

Comment 2:

Ah, I see.
Yes, it is not 6g. I run 'go test'.

@rsc
Copy link
Contributor

rsc commented Feb 17, 2012

Comment 3:

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

Owner changed to builder@golang.org.

Status changed to Accepted.

@griesemer
Copy link
Contributor

Comment 4:

See: http://golang.org/cl/5683079
Also: I filed issue #3106 - in general the go/parser could provide a better error message
in this case.

Owner changed to @griesemer.

@griesemer
Copy link
Contributor

Comment 5:

This issue was closed by revision 548591b.

Status changed to Fixed.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@rsc rsc removed the priority-go1 label Apr 10, 2015
@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.
Projects
None yet
Development

No branches or pull requests

4 participants