go/scanner: better panic diagnostic

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5787045
This commit is contained in:
Robert Griesemer 2012-03-07 16:57:26 -08:00
parent a2f0397121
commit 5827dd052c

View File

@ -109,7 +109,7 @@ const (
func (s *Scanner) Init(file *token.File, src []byte, err ErrorHandler, mode Mode) {
// Explicitly initialize all fields since a scanner may be reused.
if file.Size() != len(src) {
panic("file size does not match src len")
panic(fmt.Sprintf("file size (%d) does not match src len (%d)", file.Size(), len(src)))
}
s.file = file
s.dir, _ = filepath.Split(file.Name())