]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile/internal/syntax: cleanup panic calls
authorRobert Griesemer <gri@golang.org>
Thu, 5 Aug 2021 04:17:54 +0000 (21:17 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 6 Aug 2021 20:34:48 +0000 (20:34 +0000)
End-users are not expected to deal with the details of panics,
so providing extra information such as an "internal error" prefix
is not helpful.

Matches the types2 changes made in https://golang.org/cl/339969 .

Change-Id: Icb34a9daab981a84f41f8ae7ae5dc1b85b2d2c81
Reviewed-on: https://go-review.googlesource.com/c/go/+/339904
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/syntax/parser.go
src/cmd/compile/internal/syntax/positions.go
src/cmd/compile/internal/syntax/walk.go

index 503dea7fae6ed295b42358078d1dd1eed8133d97..acffd8488551688b342405b05e4191683cd9e830 100644 (file)
@@ -604,7 +604,7 @@ func (p *parser) typeDecl(group *Group) Decl {
                        } else {
                                // x is the array length expression
                                if debug && x == nil {
-                                       panic("internal error: nil expression")
+                                       panic("length expression is nil")
                                }
                                d.Type = p.arrayType(pos, x)
                        }
index b00f86c67cdab32322449056a2caf9c7e7aa7a50..93596559a02328a3a23296c15ffa2983630a20a1 100644 (file)
@@ -12,7 +12,7 @@ func StartPos(n Node) Pos {
        for m := n; ; {
                switch n := m.(type) {
                case nil:
-                       panic("internal error: nil")
+                       panic("nil node")
 
                // packages
                case *File:
@@ -124,7 +124,7 @@ func EndPos(n Node) Pos {
        for m := n; ; {
                switch n := m.(type) {
                case nil:
-                       panic("internal error: nil")
+                       panic("nil node")
 
                // packages
                case *File:
index ef213daf7d124c77597bc7ddc43212bab6661880..b02584420488442a3e284d5b611fa025001bd59e 100644 (file)
@@ -70,7 +70,7 @@ type walker struct {
 
 func (w walker) node(n Node) {
        if n == nil {
-               panic("invalid syntax tree: nil node")
+               panic("nil node")
        }
 
        w.v = w.v.Visit(n)