]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile/internal/ir: more useful Fatalfs
authorMatthew Dempsky <mdempsky@google.com>
Mon, 17 May 2021 18:40:21 +0000 (11:40 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 18 May 2021 20:23:13 +0000 (20:23 +0000)
This CL just adds some additional details to existing Fatalf messages
that make them more useful for identifying what went wrong.

Change-Id: Icba0d943ccfb1b810a1ede0977cc8cf22b2afde5
Reviewed-on: https://go-review.googlesource.com/c/go/+/320612
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
src/cmd/compile/internal/ir/func.go
src/cmd/compile/internal/ir/node.go
src/cmd/compile/internal/ir/val.go

index 20fe965711df33896e2f8025ea91b450a863dc4d..a4231a1bcb6e62355268803beb11ee609a07451f 100644 (file)
@@ -279,7 +279,7 @@ func FuncSymName(s *types.Sym) string {
 // MarkFunc marks a node as a function.
 func MarkFunc(n *Name) {
        if n.Op() != ONAME || n.Class != Pxxx {
-               base.Fatalf("expected ONAME/Pxxx node, got %v", n)
+               base.FatalfAt(n.Pos(), "expected ONAME/Pxxx node, got %v (%v/%v)", n, n.Op(), n.Class)
        }
 
        n.Class = PFUNC
index af559cc0820cc3e74ebd3065630e558c008e3e53..9191eeb1d6cda6f5b3aaf1f25d9325c4bcc4fe48 100644 (file)
@@ -563,7 +563,7 @@ func OuterValue(n Node) Node {
        for {
                switch nn := n; nn.Op() {
                case OXDOT:
-                       base.Fatalf("OXDOT in walk")
+                       base.FatalfAt(n.Pos(), "OXDOT in walk: %v", n)
                case ODOT:
                        nn := nn.(*SelectorExpr)
                        n = nn.X
index 03c320e205dbfdf8b6b46eb7d3d9adcc8295c46d..af9f95b29d7a7367cc0fa67b1f4a3c82f68906f7 100644 (file)
@@ -66,7 +66,7 @@ func Float64Val(v constant.Value) float64 {
 
 func AssertValidTypeForConst(t *types.Type, v constant.Value) {
        if !ValidTypeForConst(t, v) {
-               base.Fatalf("%v does not represent %v", t, v)
+               base.Fatalf("%v does not represent %v (%v)", t, v, v.Kind())
        }
 }