1
0
mirror of https://github.com/golang/go synced 2024-11-18 09:44:50 -07:00

cmd/compile: better error for malformed packages

Fixes #14270.

Change-Id: Iaf2496a24b1aba443391b90951cef472add73f13
Reviewed-on: https://go-review.googlesource.com/45950
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Matthew Dempsky 2017-06-15 13:52:13 -07:00
parent 6ce5067117
commit eb86abaa36

View File

@ -964,7 +964,8 @@ func importfile(f *Val) *types.Pkg {
// check object header
p, err := imp.ReadString('\n')
if err != nil {
log.Fatalf("reading input: %v", err)
yyerror("import %s: reading input: %v", file, err)
errorexit()
}
if len(p) > 0 {
p = p[:len(p)-1]
@ -979,7 +980,8 @@ func importfile(f *Val) *types.Pkg {
}
p, err = imp.ReadString('\n')
if err != nil {
log.Fatalf("reading input: %v", err)
yyerror("import %s: reading input: %v", file, err)
errorexit()
}
if len(p) > 0 {
p = p[:len(p)-1]
@ -1004,7 +1006,8 @@ func importfile(f *Val) *types.Pkg {
for {
p, err = imp.ReadString('\n')
if err != nil {
log.Fatalf("reading input: %v", err)
yyerror("import %s: reading input: %v", file, err)
errorexit()
}
if p == "\n" {
break // header ends with blank line