You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ cat x.go
package p
import (
"strings"
"testing"
. "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).
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: