]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile: use "init... cycle" instead of "init... loop" in error messages
authorRobert Griesemer <gri@golang.org>
Thu, 22 Sep 2022 03:52:00 +0000 (20:52 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 23 Sep 2022 20:27:09 +0000 (20:27 +0000)
For #55326.

Change-Id: Ia3c1124305986dcd49ac769e700055b263cfbd59
Reviewed-on: https://go-review.googlesource.com/c/go/+/432615
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
43 files changed:
src/cmd/compile/internal/types2/initorder.go
test/fixedbugs/bug13343.go
test/fixedbugs/bug223.go
test/fixedbugs/bug413.go
test/fixedbugs/bug459.go
test/fixedbugs/bug463.go
test/fixedbugs/issue23093.go
test/fixedbugs/issue23094.go
test/fixedbugs/issue4847.go
test/fixedbugs/issue52748.go
test/fixedbugs/issue6703a.go
test/fixedbugs/issue6703b.go
test/fixedbugs/issue6703c.go
test/fixedbugs/issue6703d.go
test/fixedbugs/issue6703e.go
test/fixedbugs/issue6703f.go
test/fixedbugs/issue6703g.go
test/fixedbugs/issue6703h.go
test/fixedbugs/issue6703i.go
test/fixedbugs/issue6703j.go
test/fixedbugs/issue6703k.go
test/fixedbugs/issue6703l.go
test/fixedbugs/issue6703m.go
test/fixedbugs/issue6703n.go
test/fixedbugs/issue6703o.go
test/fixedbugs/issue6703p.go
test/fixedbugs/issue6703q.go
test/fixedbugs/issue6703r.go
test/fixedbugs/issue6703s.go
test/fixedbugs/issue6703t.go
test/fixedbugs/issue6703u.go
test/fixedbugs/issue6703v.go
test/fixedbugs/issue6703w.go
test/fixedbugs/issue6703x.go
test/fixedbugs/issue6703y.go
test/fixedbugs/issue6703z.go
test/fixedbugs/issue7525.go
test/fixedbugs/issue7525b.go
test/fixedbugs/issue7525c.go
test/fixedbugs/issue7525d.go
test/fixedbugs/issue7525e.go
test/initexp.go
test/typecheckloop.go

index cf6110baa92c0f918b201af3bfe05f9e7f4d2586..5f5334e1b8b88e532dd1a776cb6365e0b27fd5bb 100644 (file)
@@ -153,11 +153,7 @@ func findPath(objMap map[Object]*declInfo, from, to Object, seen map[Object]bool
 func (check *Checker) reportCycle(cycle []Object) {
        obj := cycle[0]
        var err error_
-       if check.conf.CompilerErrorMessages {
-               err.errorf(obj, "initialization loop for %s", obj.Name())
-       } else {
-               err.errorf(obj, "initialization cycle for %s", obj.Name())
-       }
+       err.errorf(obj, "initialization cycle for %s", obj.Name())
        // subtle loop: print cycle[i] for i = 0, n-1, n-2, ... 1 for len(cycle) = n
        for i := len(cycle) - 1; i >= 0; i-- {
                err.errorf(obj, "%s refers to", obj.Name())
index a7febeae7e0c00e6606ed173857ec8b1fcf9f34c..75b3f017e7bcda055c43e291de6b5d0c810ef96a 100644 (file)
@@ -7,7 +7,7 @@
 package main
 
 var (
-       a, b = f() // ERROR "initialization loop|depends upon itself|depend upon each other"
+       a, b = f() // ERROR "initialization cycle|depends upon itself|depend upon each other"
        c    = b   // GCCGO_ERROR "depends upon itself|depend upon each other"
 )
 
index 50082cbab1beeed5522803a4cb5ee08831bba05c..3aa7dda4049680b2d3ec55ba738c408d070d6e16 100644 (file)
@@ -4,7 +4,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// check that initialization loop is diagnosed
+// check that initialization cycle is diagnosed
 // and that closure cannot be used to hide it.
 // error message is not standard format, so no errchk above.
 
@@ -18,4 +18,4 @@ func f() {
        }
 }
 
-var m = map[string]F{"f": f} // ERROR "initialization loop|depends upon itself|initialization cycle"
+var m = map[string]F{"f": f} // ERROR "initialization cycle|depends upon itself|initialization cycle"
index 819bd1a984ea4286b50c57ee5ea908618c609501..e22279e15c5daf9b44df60f19ba07d565e1df58e 100644 (file)
@@ -8,4 +8,4 @@ package p
 
 func f(i int) int { return i }
 
-var i = func() int {a := f(i); return a}()  // ERROR "initialization loop|depends upon itself"
+var i = func() int {a := f(i); return a}()  // ERROR "initialization cycle|depends upon itself"
index c71cb1bd082ecb2b4e82d1482b813e9e521ee7f6..a404d218e09b6cdf2947a6299e0d4f273e6991b8 100644 (file)
@@ -4,12 +4,12 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// Issue 3890: missing detection of init loop involving
+// Issue 3890: missing detection of init cycle involving
 // method calls in function bodies.
 
 package flag
 
-var commandLine = NewFlagSet() // ERROR "loop|depends upon itself"
+var commandLine = NewFlagSet() // ERROR "initialization cycle|depends upon itself"
 
 type FlagSet struct {
 }
index ed546bf74163da11b865a9ba0e87af246c3a7e5f..36515f8961c747cf933398684d58f2b1122db138 100644 (file)
@@ -9,11 +9,11 @@
 
 package main
 
-const a = a // ERROR "refers to itself|definition loop|initialization loop"
+const a = a // ERROR "refers to itself|definition loop|initialization cycle"
 
 const (
        X    = A
-       A    = B // ERROR "refers to itself|definition loop|initialization loop"
+       A    = B // ERROR "refers to itself|definition loop|initialization cycle"
        B    = D
        C, D = 1, A
 )
index 7b2865ca41de6b7394b6dd0da7124b6a671a7b20..0d3b13e633a509589abdc7bac608ac4d5c81a4a2 100644 (file)
@@ -6,4 +6,4 @@
 
 package p
 
-var f = func() { f() } // ERROR "initialization loop|initialization expression for .*f.* depends upon itself"
+var f = func() { f() } // ERROR "initialization cycle|initialization expression for .*f.* depends upon itself"
index 853b19b92f38fe1216c61a2aa91baabb3da496fa..7c58cad5627e26c19a7abda84caef885e7fe2f13 100644 (file)
@@ -8,4 +8,4 @@
 
 package p
 
-var a [len(a)]int // ERROR "\[len\(a\)\]int|initialization loop"
+var a [len(a)]int // ERROR "\[len\(a\)\]int|initialization cycle"
index 91a6568f27194ac02626081ccb50217b57378b19..176525e14c169dd1504c5679bf43dfae953138aa 100644 (file)
@@ -4,7 +4,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// Issue 4847: initialization loop is not detected.
+// Issue 4847: initialization cycle is not detected.
 
 package p
 
@@ -19,6 +19,6 @@ func matchList(s *S) E { return matcher(matchAnyFn)(s) }
 
 var foo = matcher(matchList)
 
-var matchAny = matcher(matchList) // ERROR "initialization loop|depends upon itself"
+var matchAny = matcher(matchList) // ERROR "initialization cycle|depends upon itself"
 
 func matchAnyFn(s *S) (err E) { return matchAny(s) }
index 42973c01e50d4fd1da1cc608a66e5be05507d5a2..e9f7ea0510e7cdd53cf339f3a4ef0f28d29370f6 100644 (file)
@@ -10,4 +10,4 @@ import "unsafe"
 
 type S[T any] struct{}
 
-const c = unsafe.Sizeof(S[[c]byte]{}) // ERROR "initialization loop"
+const c = unsafe.Sizeof(S[[c]byte]{}) // ERROR "initialization cycle"
index 38c59562d08755ca9e660aa30266e2601f63aa16..fe736f5bc6fdcf67ad4f88cacbe58bfcf7ddebbd 100644 (file)
@@ -13,4 +13,4 @@ func fx() int {
        return 0
 }
 
-var x = fx // ERROR "initialization loop|depends upon itself"
+var x = fx // ERROR "initialization cycle|depends upon itself"
index 35438c3b7454f30471c6e4c527a928c440c6ceb3..41510945c5a0358bf6bfca7437db557065573302 100644 (file)
@@ -13,4 +13,4 @@ func fx() int {
        return 0
 }
 
-var x = fx() // ERROR "initialization loop|depends upon itself"
+var x = fx() // ERROR "initialization cycle|depends upon itself"
index ade40e33d42ded3f635a3f1bed87127ea946cca2..73d686c696ac1ce3aef22abdd2b0b652aa5c1287 100644 (file)
@@ -15,4 +15,4 @@ func (T) m() int {
        return 0
 }
 
-var x = T.m // ERROR "initialization loop|depends upon itself"
+var x = T.m // ERROR "initialization cycle|depends upon itself"
index dd481636bd0adda3113ecd8a72db1b26fa17e90d..5d77c846cb4d0dd6bc2822befcccab589e787d44 100644 (file)
@@ -15,4 +15,4 @@ func (T) m() int {
        return 0
 }
 
-var x = T.m(0) // ERROR "initialization loop|depends upon itself"
+var x = T.m(0) // ERROR "initialization cycle|depends upon itself"
index d362d6e83284af4c152f5e8b8df65b8171476066..604d4bfa5dd275cdba940d879fe76cc07854c11d 100644 (file)
@@ -15,4 +15,4 @@ func (T) m() int {
        return 0
 }
 
-var x = T(0).m // ERROR "initialization loop|depends upon itself"
+var x = T(0).m // ERROR "initialization cycle|depends upon itself"
index 0b49026a69af33bcc1e636a324cf73fefac8d4fe..06c9cdff42d0c637532d75aec42bfd65f80f0cf1 100644 (file)
@@ -15,4 +15,4 @@ func (T) m() int {
        return 0
 }
 
-var x = T(0).m() // ERROR "initialization loop|depends upon itself"
+var x = T(0).m() // ERROR "initialization cycle|depends upon itself"
index 05ec7405f3f9e57f7ee6717d2a58f34e86e66e8e..a2ca5a3e697f30adf1cb7c68e4a12eb8137b7d58 100644 (file)
@@ -17,4 +17,4 @@ func (T) m() int {
 
 type E struct{ T }
 
-var x = E.m // ERROR "initialization loop|depends upon itself" 
+var x = E.m // ERROR "initialization cycle|depends upon itself" 
index f6b69e1b70b14926f07615b327f677fd2a8b93bf..e26ce6a7e2b4cfb8535a9f13ab4d636c0ecbac7a 100644 (file)
@@ -17,4 +17,4 @@ func (T) m() int {
 
 type E struct{ T }
 
-var x = E.m(E{0}) // ERROR "initialization loop|depends upon itself" 
+var x = E.m(E{0}) // ERROR "initialization cycle|depends upon itself" 
index fb580a2461021ff09abb6eff1b05da7337b421d1..af485b570d0f7fb04db6ba90a1c28465ad4c79ae 100644 (file)
@@ -17,4 +17,4 @@ func (T) m() int {
 
 type E struct{ T }
 
-var x = E{}.m // ERROR "initialization loop|depends upon itself" 
+var x = E{}.m // ERROR "initialization cycle|depends upon itself" 
index b4c079f808d1a77d955ad8304932bc5e96f4e2b1..0b72250f800664aa839d3521f9dfb5386ab0706e 100644 (file)
@@ -17,4 +17,4 @@ func (T) m() int {
 
 type E struct{ T }
 
-var x = E{}.m() // ERROR "initialization loop|depends upon itself"
+var x = E{}.m() // ERROR "initialization cycle|depends upon itself"
index 6f606e297608ab29924a75b229b23dc0c931567f..fad8edd1c8bce533f51afa876c1f955d71e5389e 100644 (file)
@@ -17,5 +17,5 @@ func (T) m() int {
 
 var (
        t T
-       x = t.m // ERROR "initialization loop|depends upon itself"
+       x = t.m // ERROR "initialization cycle|depends upon itself"
 )
index 684c2250021a886095428cc4b9e90ddea12dbc08..750c95e731ff8e8830c49036ca6346b86b771b0b 100644 (file)
@@ -17,5 +17,5 @@ func (T) m() int {
 
 var (
        t T
-       x = t.m() // ERROR "initialization loop|depends upon itself"
+       x = t.m() // ERROR "initialization cycle|depends upon itself"
 )
index 7d1b604860ae6aaeb776376a82933f879e8f3812..76469594060db719f19d6bb03a1be952ef9fcceb 100644 (file)
@@ -21,5 +21,5 @@ func f() T {
 
 var (
        t T
-       x = f().m // ERROR "initialization loop|depends upon itself"
+       x = f().m // ERROR "initialization cycle|depends upon itself"
 )
index 22646af783c87e1cbfef4a3fc01e8a89d67429e5..339789206bc485ef2e460b3255b939d4e652cc69 100644 (file)
@@ -21,5 +21,5 @@ func f() T {
 
 var (
        t T
-       x = f().m() // ERROR "initialization loop|depends upon itself"
+       x = f().m() // ERROR "initialization cycle|depends upon itself"
 )
index a11fdfd858e7faabd50c157b065b4eff0d801c63..87d706bbe8fbeefb90143c9d518e85620314db2b 100644 (file)
@@ -19,5 +19,5 @@ type E struct{ T }
 
 var (
        e E
-       x = e.m // ERROR "initialization loop|depends upon itself" 
+       x = e.m // ERROR "initialization cycle|depends upon itself" 
 )
index 3ac7a63de88fcf0d6320abc3f3d941cf2ca22426..24ef94a72f4cc747fa5e6719288f82c546ab65c3 100644 (file)
@@ -19,5 +19,5 @@ type E struct{ T }
 
 var (
        e E
-       x = e.m() // ERROR "initialization loop|depends upon itself" 
+       x = e.m() // ERROR "initialization cycle|depends upon itself" 
 )
index b087c15d37b5ade34bd665f26bdcc18eb9922298..92bcab92fa04864aa3589cf9f6ce69b3d5d12d43 100644 (file)
@@ -24,5 +24,5 @@ type E struct{ T }
 
 var (
        e E
-       x = g().m // ERROR "initialization loop|depends upon itself" 
+       x = g().m // ERROR "initialization cycle|depends upon itself" 
 )
index de514f1802ab3f340c82a35ab1580e1acf8c64a0..2b538ffa0475ca0634d30f423d55f8d248f107c9 100644 (file)
@@ -24,5 +24,5 @@ type E struct{ T }
 
 var (
        e E
-       x = g().m() // ERROR "initialization loop|depends upon itself" 
+       x = g().m() // ERROR "initialization cycle|depends upon itself" 
 )
index cd3c5b342f5138231b18075033c3eab758032521..74ab3866feb07ff8c84ecee894c96a30e946e79f 100644 (file)
@@ -15,4 +15,4 @@ func (*T) pm() int {
        return 0
 }
 
-var x = (*T).pm // ERROR "initialization loop|depends upon itself"
+var x = (*T).pm // ERROR "initialization cycle|depends upon itself"
index 62de37c578488851e8a0e50ad5a3f96bb961a3ae..e9266b0c32c5a693626c481401c4f705ef7f5da2 100644 (file)
@@ -15,4 +15,4 @@ func (*T) pm() int {
        return 0
 }
 
-var x = (*T).pm(nil) // ERROR "initialization loop|depends upon itself"
+var x = (*T).pm(nil) // ERROR "initialization cycle|depends upon itself"
index 961a0001c343448cb1c1fa1d1fd45ed7a4e3723e..9b03c17139f5a886781e75b00ce11312de43a588 100644 (file)
@@ -15,4 +15,4 @@ func (*T) pm() int {
        return 0
 }
 
-var x = (*T)(nil).pm // ERROR "initialization loop|depends upon itself"
+var x = (*T)(nil).pm // ERROR "initialization cycle|depends upon itself"
index 2409911ae658de76f85f8878f018151ec150c5c1..349289cb90f50629611b255f7d119609c705ec01 100644 (file)
@@ -15,4 +15,4 @@ func (*T) pm() int {
        return 0
 }
 
-var x = (*T)(nil).pm() // ERROR "initialization loop|depends upon itself"
+var x = (*T)(nil).pm() // ERROR "initialization cycle|depends upon itself"
index b7b3d91a2fc4887677ef61ae4c8cd13e99745393..846b5f8c7df5856f0fc5b2c8622301f87f5da198 100644 (file)
@@ -17,5 +17,5 @@ func (*T) pm() int {
 
 var (
        p *T
-       x = p.pm // ERROR "initialization loop|depends upon itself"
+       x = p.pm // ERROR "initialization cycle|depends upon itself"
 )
index 48daf03a9925ca4468c10eed3e2c4156fe191ad6..828c09af21eee36d1c87ed784323c96a419c4db4 100644 (file)
@@ -17,5 +17,5 @@ func (*T) pm() int {
 
 var (
        p *T
-       x = p.pm() // ERROR "initialization loop|depends upon itself"
+       x = p.pm() // ERROR "initialization cycle|depends upon itself"
 )
index 278dfcdb5e0b2a5cbda83d1c84112cb0b07b1b82..01b8abd7aca9759d20e53e05cb59ac4a0875227c 100644 (file)
@@ -20,4 +20,4 @@ func pf() *T {
        return nil
 }
 
-var x = pf().pm // ERROR "initialization loop|depends upon itself" 
+var x = pf().pm // ERROR "initialization cycle|depends upon itself" 
index f81a3a8c341f56ef742cf1931cb8560ac86fc086..76c17e2bb5a363318715e3f59762698b0b0c3d9b 100644 (file)
@@ -20,4 +20,4 @@ func pf() *T {
        return nil
 }
 
-var x = pf().pm() // ERROR "initialization loop|depends upon itself" 
+var x = pf().pm() // ERROR "initialization cycle|depends upon itself" 
index b292d66ff162b84d2e8ac7b4cd444e582fdf962a..05e26d19153f1ffd3b867c4dbb17a0cb2c577d32 100644 (file)
@@ -10,6 +10,6 @@ package main
 
 import "unsafe"
 
-var x struct { // GC_ERROR "initialization loop for x"
+var x struct { // GC_ERROR "initialization cycle for x"
        a [unsafe.Sizeof(x.a)]int // GCCGO_ERROR "array bound|typechecking loop|invalid expression"
 }
index 139408eb79099151055d2bc7d1b8e72cd245aa90..b72d12fbb7a04fb96961c2cb84360c62646c8f40 100644 (file)
@@ -8,6 +8,6 @@
 
 package main
 
-var y struct { // GC_ERROR "initialization loop for y"
+var y struct { // GC_ERROR "initialization cycle for y"
        d [len(y.d)]int // GCCGO_ERROR "array bound|typechecking loop|invalid array"
 }
index 94481597ee1b198a9c076ae521ca36fe4e7d6d32..8d51154a35aa08a492249b8815324d5899b0ab61 100644 (file)
@@ -8,6 +8,6 @@
 
 package main
 
-var z struct { // GC_ERROR "initialization loop for z"
+var z struct { // GC_ERROR "initialization cycle for z"
        e [cap(z.e)]int // GCCGO_ERROR "array bound|typechecking loop|invalid array"
 }
index 62d465930a430490f6757a190a6d08d1b5a3f682..cedb9f7b314f1084d7424aaaa1edfec746748fc1 100644 (file)
@@ -10,6 +10,6 @@ package main
 
 import "unsafe"
 
-var x struct { // GC_ERROR "initialization loop for x"
+var x struct { // GC_ERROR "initialization cycle for x"
        b [unsafe.Offsetof(x.b)]int // GCCGO_ERROR "array bound|typechecking loop|invalid array"
 }
index 150df074edad4546bfb32ad609e437563ad80145..574639752164886843e438a58ce53b70b2c5d378 100644 (file)
@@ -10,6 +10,6 @@ package main
 
 import "unsafe"
 
-var x struct { // GC_ERROR "initialization loop for x"
+var x struct { // GC_ERROR "initialization cycle for x"
        c [unsafe.Alignof(x.c)]int // GCCGO_ERROR "array bound|typechecking loop|invalid array"
 }
index f279a7c5289cc6e020a7297b7e51f5ae5e14c92c..b4d4701aab7707ca56dbc9daf78eda76ce3d7044 100644 (file)
@@ -12,7 +12,7 @@ package p
 // and runs in a fraction of a second without it.
 // 10 seconds (-t 10 above) should be plenty if the code is working.
 
-var x = f() + z() // ERROR "initialization loop"
+var x = f() + z() // ERROR "initialization cycle"
 
 func f() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
 func z() int { return x }
index 13f413cfc9288fd61fe8196415f66c6e8a9f7530..a143e0984ce79a7ba437a1b113364aa99e7e83a2 100644 (file)
@@ -9,6 +9,6 @@
 
 package main
 
-const A = 1 + B // ERROR "constant definition loop\n.*A uses B\n.*B uses C\n.*C uses A|initialization loop"
-const B = C - 1 // ERROR "constant definition loop\n.*B uses C\n.*C uses B|initialization loop"
+const A = 1 + B // ERROR "constant definition loop\n.*A uses B\n.*B uses C\n.*C uses A|initialization cycle"
+const B = C - 1 // ERROR "constant definition loop\n.*B uses C\n.*C uses B|initialization cycle"
 const C = A + B + 1