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/parser: too many errors from typing == as = #4519

rsc opened this issue Dec 10, 2012 · 1 comment

go/parser: too many errors from typing == as = #4519

rsc opened this issue Dec 10, 2012 · 1 comment


Copy link

rsc commented Dec 10, 2012

$ cat x.go
package p

import (
    . "bufio"

type negativeReader int

func (*negativeReader) Read([]byte) (int, error) {panic(1)}

func TestNegativeRead(t *testing.T) {
    // should panic with a description pointing at the reader, not at itself.
    // (should NOT panic with slice index error, for example.)
    b := NewReader(new(negativeReader))
    defer func() {
        if err := recover(); err = nil {
            t.Fatal("read did not panic")
        } else if !strings.Contains(err.Error(), "reader returned negative count from Read") {
            t.Fatal("wrong panic: %v", err)
    b.Read(make([]byte, 100))

$ gofmt x.go
x.go:17:8: expected function/method call
x.go:18:28: expected '{', found '='
x.go:19:33: missing ',' before newline in composite literal
x.go:20:5: expected ';', found 'else'
x.go:23:3: expected ';', found '('
x.go:25:3: expected '}', found 'EOF'

$ go tool 6g x.go
x.go:18: err = nil used as value
x.go:20: err.Error undefined (type interface {} has no field or method Error)

It would be nice if the parser could handle seeing an assignment where an expression was
expected a bit more gracefully. Ideally it would produce just the single line of output
that 6g does (at x.go:18).
Copy link

Comment 1:

This issue was closed by revision 916f4cf.

Status changed to Fixed.

@rsc rsc added fixed labels Mar 11, 2013
@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 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.
None yet

No branches or pull requests

3 participants