diff options
author | Robert Griesemer <gri@golang.org> | 2023-03-09 16:21:22 -0800 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2023-03-10 18:22:02 +0000 |
commit | 2cbab4e98c6091f5fb6cb73bdebfe328793da388 (patch) | |
tree | 41fc9cf8552f5e9a932458314d7a279aa3f64847 /src/cmd/compile/internal/base/print.go | |
parent | 3790ceca9735432486ba34da28f214349e4c1e7e (diff) | |
download | go-git-2cbab4e98c6091f5fb6cb73bdebfe328793da388.tar.gz |
cmd/compile: pass type checker error codes in the compiler
Pass type checker error codes to base.ErrorfAt function calls
in the compiler (but don't do anything yet with the code).
Also, provide error codes to base.ErrorfAt calls in the
compiler as needed.
This opens the door towards reporting the error code and/or
providing a link/reference to more detailed explanations
(see internal/types/errors/codes.go).
Change-Id: I0ff9368d8163499ffdac6adfe8331fdc4a19b4b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/475198
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/base/print.go')
-rw-r--r-- | src/cmd/compile/internal/base/print.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/base/print.go b/src/cmd/compile/internal/base/print.go index 21fa001457..6d21c33254 100644 --- a/src/cmd/compile/internal/base/print.go +++ b/src/cmd/compile/internal/base/print.go @@ -7,6 +7,7 @@ package base import ( "fmt" "internal/buildcfg" + "internal/types/errors" "os" "runtime/debug" "sort" @@ -105,11 +106,11 @@ func sameline(a, b src.XPos) bool { // Errorf reports a formatted error at the current line. func Errorf(format string, args ...interface{}) { - ErrorfAt(Pos, format, args...) + ErrorfAt(Pos, 0, format, args...) } // ErrorfAt reports a formatted error message at pos. -func ErrorfAt(pos src.XPos, format string, args ...interface{}) { +func ErrorfAt(pos src.XPos, code errors.Code, format string, args ...interface{}) { msg := fmt.Sprintf(format, args...) if strings.HasPrefix(msg, "syntax error") { |