]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/types2: record error code in Error struct
authorRobert Griesemer <gri@golang.org>
Thu, 9 Mar 2023 22:44:46 +0000 (14:44 -0800)
committerGopher Robot <gobot@golang.org>
Fri, 10 Mar 2023 17:17:25 +0000 (17:17 +0000)
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>
src/cmd/compile/internal/types2/api.go
src/cmd/compile/internal/types2/errors.go

index e60396b14314eaffd12ac0e60668e3cfaa2d5bc7..56fb5789431433703d631a251b4d6e26a3be00b6 100644 (file)
@@ -27,6 +27,7 @@ import (
        "cmd/compile/internal/syntax"
        "fmt"
        "go/constant"
+       . "internal/types/errors"
        "strings"
 )
 
@@ -39,6 +40,7 @@ type Error struct {
        Msg  string     // default error message, user-friendly
        Full string     // full error message, for debugging (may contain internal details)
        Soft bool       // if set, error is "soft"
+       Code Code       // error code
 }
 
 // Error returns an error string formatted as follows:
index 8bbd71933515c95203bb1ee982b2c178d3a0660d..bbe4cc3feaa63adfe5f8156af460fec796e71530 100644 (file)
@@ -250,7 +250,7 @@ func (check *Checker) err(at poser, code Code, msg string, soft bool) {
                pos = check.errpos
        }
 
-       err := Error{pos, stripAnnotations(msg), msg, soft}
+       err := Error{pos, stripAnnotations(msg), msg, soft, code}
        if check.firstErr == nil {
                check.firstErr = err
        }