1
0
mirror of https://github.com/golang/go synced 2024-11-17 17:54:48 -07:00

cmd/compile/internal/types2: record error code in Error struct

go/types already does this, if slightly differently.

Change-Id: I9cf5f493714d865deec5ad23e2ee9b5c5d3f2f0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/475197
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Robert Griesemer 2023-03-09 14:44:46 -08:00 committed by Gopher Robot
parent 49588d0c55
commit ad3ea0134f
2 changed files with 3 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import (
"cmd/compile/internal/syntax" "cmd/compile/internal/syntax"
"fmt" "fmt"
"go/constant" "go/constant"
. "internal/types/errors"
"strings" "strings"
) )
@ -39,6 +40,7 @@ type Error struct {
Msg string // default error message, user-friendly Msg string // default error message, user-friendly
Full string // full error message, for debugging (may contain internal details) Full string // full error message, for debugging (may contain internal details)
Soft bool // if set, error is "soft" Soft bool // if set, error is "soft"
Code Code // error code
} }
// Error returns an error string formatted as follows: // Error returns an error string formatted as follows:

View File

@ -250,7 +250,7 @@ func (check *Checker) err(at poser, code Code, msg string, soft bool) {
pos = check.errpos pos = check.errpos
} }
err := Error{pos, stripAnnotations(msg), msg, soft} err := Error{pos, stripAnnotations(msg), msg, soft, code}
if check.firstErr == nil { if check.firstErr == nil {
check.firstErr = err check.firstErr = err
} }