aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2020-11-24 15:52:13 -0800
committerMatthew Dempsky <mdempsky@google.com>2020-11-25 03:22:35 +0000
commit4a6b4fd13965fe8428c9177bdd824a48dff553c0 (patch)
tree6a45bb4a57b04e2e267bed54919276333e57760f
parent484449c6416662c5453257c641d015c1fca681ea (diff)
downloadgo-4a6b4fd13965fe8428c9177bdd824a48dff553c0.tar.gz
go-4a6b4fd13965fe8428c9177bdd824a48dff553c0.zip
[dev.regabi] add FatalfAt and fix Fatalf docs
I've wanted a FatalfAt function for a while, but under the old "-l" suffix naming convention it would have been called "Fatalfl", which is just atrocious. Change-Id: If87f692ecdff478769426d4b054ac396e5c1e42e Reviewed-on: https://go-review.googlesource.com/c/go/+/273013 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
-rw-r--r--src/cmd/compile/internal/gc/print.go26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/cmd/compile/internal/gc/print.go b/src/cmd/compile/internal/gc/print.go
index 1dbd58df42..52585814f6 100644
--- a/src/cmd/compile/internal/gc/print.go
+++ b/src/cmd/compile/internal/gc/print.go
@@ -177,23 +177,39 @@ func Warnl(pos src.XPos, format string, args ...interface{}) {
}
}
-// Fatal reports a fatal error - an internal problem - at the current line and exits.
-// If other errors have already been printed, then Fatal just quietly exits.
+// Fatalf reports a fatal error - an internal problem - at the current line and exits.
+// If other errors have already been printed, then Fatalf just quietly exits.
// (The internal problem may have been caused by incomplete information
// after the already-reported errors, so best to let users fix those and
// try again without being bothered about a spurious internal error.)
//
// But if no errors have been printed, or if -d panic has been specified,
-// Fatal prints the error as an "internal compiler error". In a released build,
+// Fatalf prints the error as an "internal compiler error". In a released build,
// it prints an error asking to file a bug report. In development builds, it
// prints a stack trace.
//
-// If -h has been specified, Fatal panics to force the usual runtime info dump.
+// If -h has been specified, Fatalf panics to force the usual runtime info dump.
func Fatalf(format string, args ...interface{}) {
+ FatalfAt(lineno, format, args...)
+}
+
+// FatalfAt reports a fatal error - an internal problem - at pos and exits.
+// If other errors have already been printed, then FatalfAt just quietly exits.
+// (The internal problem may have been caused by incomplete information
+// after the already-reported errors, so best to let users fix those and
+// try again without being bothered about a spurious internal error.)
+//
+// But if no errors have been printed, or if -d panic has been specified,
+// FatalfAt prints the error as an "internal compiler error". In a released build,
+// it prints an error asking to file a bug report. In development builds, it
+// prints a stack trace.
+//
+// If -h has been specified, FatalfAt panics to force the usual runtime info dump.
+func FatalfAt(pos src.XPos, format string, args ...interface{}) {
flusherrors()
if Debug_panic != 0 || numErrors == 0 {
- fmt.Printf("%v: internal compiler error: ", linestr(lineno))
+ fmt.Printf("%v: internal compiler error: ", linestr(pos))
fmt.Printf(format, args...)
fmt.Printf("\n")