cmd/compile/internal/syntax: don't panic if no error handler is provided

If no error handler is provided, terminate parsing with first error
and report that error.

Fixes #17697.

Change-Id: I9070faf7239bd53725de141507912b92ded3474b
Reviewed-on: https://go-review.googlesource.com/32456
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Robert Griesemer 2016-10-31 16:58:15 -07:00
parent 53fc330e2d
commit 7a26d9fced
3 changed files with 29 additions and 6 deletions

View file

@ -155,3 +155,10 @@ func verifyPrint(filename string, ast1 *File) {
panic("not equal")
}
}
func TestIssue17697(t *testing.T) {
_, err := ReadBytes(nil, nil, nil, 0) // return with parser error, don't panic
if err == nil {
t.Errorf("no error reported")
}
}