mirror of
https://github.com/golang/go
synced 2024-11-22 16:34:47 -07:00
cmd/compile: graceful handle error in noder LoadPackage
When syntax.Parse returns error, noder.file will be nil. Currently, we continue accessing it regardlessly and depend on gc.hidePanic to hide the panic from user. Instead, we should gracefully handle the error in LoadPackage, then exit earlier if any error occurred. Updates #43311 Change-Id: I0a108ef360bd4f0cc9f481071b8967355e1513af Reviewed-on: https://go-review.googlesource.com/c/go/+/294030 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
4532467c18
commit
b7f4307761
@ -68,6 +68,9 @@ func LoadPackage(filenames []string) {
|
||||
for e := range p.err {
|
||||
p.errorAt(e.Pos, "%s", e.Msg)
|
||||
}
|
||||
if p.file == nil {
|
||||
base.ErrorExit()
|
||||
}
|
||||
lines += p.file.EOF.Line()
|
||||
}
|
||||
base.Timer.AddEvent(int64(lines), "lines")
|
||||
|
@ -1,4 +1,4 @@
|
||||
// errorcheck
|
||||
// errorcheck -d=panic
|
||||
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
|
Loading…
Reference in New Issue
Block a user