Skip to content

Commit

Permalink
cmd/compile: better error for malformed packages
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mdempsky committed Jun 15, 2017
1 parent 6ce5067 commit eb86aba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/cmd/compile/internal/gc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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
Expand Down

0 comments on commit eb86aba

Please sign in to comment.