From eb86abaa36097971d1cd52c1479da246f2b49073 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Thu, 15 Jun 2017 13:52:13 -0700 Subject: [PATCH] cmd/compile: better error for malformed packages Fixes #14270. Change-Id: Iaf2496a24b1aba443391b90951cef472add73f13 Reviewed-on: https://go-review.googlesource.com/45950 Run-TryBot: Matthew Dempsky Reviewed-by: Robert Griesemer TryBot-Result: Gobot Gobot --- src/cmd/compile/internal/gc/main.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index 87d8440d1c..57c6600b15 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -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