aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/staticdata
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2023-03-09 16:21:22 -0800
committerGopher Robot <gobot@golang.org>2023-03-10 18:22:02 +0000
commit2cbab4e98c6091f5fb6cb73bdebfe328793da388 (patch)
tree41fc9cf8552f5e9a932458314d7a279aa3f64847 /src/cmd/compile/internal/staticdata
parent3790ceca9735432486ba34da28f214349e4c1e7e (diff)
downloadgo-2cbab4e98c6091f5fb6cb73bdebfe328793da388.tar.xz
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/staticdata')
-rw-r--r--src/cmd/compile/internal/staticdata/data.go2
-rw-r--r--src/cmd/compile/internal/staticdata/embed.go14
2 files changed, 8 insertions, 8 deletions
diff --git a/src/cmd/compile/internal/staticdata/data.go b/src/cmd/compile/internal/staticdata/data.go
index 662580f8e2..e39d0ee6a5 100644
--- a/src/cmd/compile/internal/staticdata/data.go
+++ b/src/cmd/compile/internal/staticdata/data.go
@@ -214,7 +214,7 @@ func dstringdata(s *obj.LSym, off int, t string, pos src.XPos, what string) int
// causing a cryptic error message by the linker. Check for oversize objects here
// and provide a useful error message instead.
if int64(len(t)) > 2e9 {
- base.ErrorfAt(pos, "%v with length %v is too big", what, len(t))
+ base.ErrorfAt(pos, 0, "%v with length %v is too big", what, len(t))
return 0
}
diff --git a/src/cmd/compile/internal/staticdata/embed.go b/src/cmd/compile/internal/staticdata/embed.go
index 8d4dedff59..a4d493ce5e 100644
--- a/src/cmd/compile/internal/staticdata/embed.go
+++ b/src/cmd/compile/internal/staticdata/embed.go
@@ -31,11 +31,11 @@ func embedFileList(v *ir.Name, kind int) []string {
for _, pattern := range e.Patterns {
files, ok := base.Flag.Cfg.Embed.Patterns[pattern]
if !ok {
- base.ErrorfAt(e.Pos, "invalid go:embed: build system did not map pattern: %s", pattern)
+ base.ErrorfAt(e.Pos, 0, "invalid go:embed: build system did not map pattern: %s", pattern)
}
for _, file := range files {
if base.Flag.Cfg.Embed.Files[file] == "" {
- base.ErrorfAt(e.Pos, "invalid go:embed: build system did not map file: %s", file)
+ base.ErrorfAt(e.Pos, 0, "invalid go:embed: build system did not map file: %s", file)
continue
}
if !have[file] {
@@ -57,7 +57,7 @@ func embedFileList(v *ir.Name, kind int) []string {
if kind == embedString || kind == embedBytes {
if len(list) > 1 {
- base.ErrorfAt(v.Pos(), "invalid go:embed: multiple files for type %v", v.Type())
+ base.ErrorfAt(v.Pos(), 0, "invalid go:embed: multiple files for type %v", v.Type())
return nil
}
}
@@ -109,12 +109,12 @@ func WriteEmbed(v *ir.Name) {
commentPos := (*v.Embed)[0].Pos
if base.Flag.Cfg.Embed.Patterns == nil {
- base.ErrorfAt(commentPos, "invalid go:embed: build system did not supply embed configuration")
+ base.ErrorfAt(commentPos, 0, "invalid go:embed: build system did not supply embed configuration")
return
}
kind := embedKind(v.Type())
if kind == embedUnknown {
- base.ErrorfAt(v.Pos(), "go:embed cannot apply to var of type %v", v.Type())
+ base.ErrorfAt(v.Pos(), 0, "go:embed cannot apply to var of type %v", v.Type())
return
}
@@ -124,7 +124,7 @@ func WriteEmbed(v *ir.Name) {
file := files[0]
fsym, size, err := fileStringSym(v.Pos(), base.Flag.Cfg.Embed.Files[file], kind == embedString, nil)
if err != nil {
- base.ErrorfAt(v.Pos(), "embed %s: %v", file, err)
+ base.ErrorfAt(v.Pos(), 0, "embed %s: %v", file, err)
}
sym := v.Linksym()
off := 0
@@ -160,7 +160,7 @@ func WriteEmbed(v *ir.Name) {
} else {
fsym, size, err := fileStringSym(v.Pos(), base.Flag.Cfg.Embed.Files[file], true, hash)
if err != nil {
- base.ErrorfAt(v.Pos(), "embed %s: %v", file, err)
+ base.ErrorfAt(v.Pos(), 0, "embed %s: %v", file, err)
}
off = objw.SymPtr(slicedata, off, fsym, 0) // data string
off = objw.Uintptr(slicedata, off, uint64(size))