indices = indices[:0]
for i, want := range errList {
pattern := strings.TrimSpace(want.Msg[len(" ERROR "):])
+ // We expect all patterns to be quoted in double quotes
+ // and then we remove the quotes.
+ // TODO(gri) use correct strconv.Unquote eventually
if n := len(pattern); n >= 2 && pattern[0] == '"' && pattern[n-1] == '"' {
pattern = pattern[1 : n-1]
+ } else {
+ t.Errorf("%s:%d:%d: unquoted pattern: %s", filename, line, want.Pos.Col(), pattern)
+ continue
}
rx, err := regexp.Compile(pattern)
if err != nil {
}
func TestSpec(t *testing.T) { testDirFiles(t, "../../../../internal/types/testdata/spec", 0, false) }
func TestExamples(t *testing.T) {
- testDirFiles(t, "../../../../internal/types/testdata/examples", 45, false)
+ testDirFiles(t, "../../../../internal/types/testdata/examples", 50, false)
} // TODO(gri) narrow column tolerance
func TestFixedbugs(t *testing.T) {
testDirFiles(t, "../../../../internal/types/testdata/fixedbugs", 100, false)
package p
// don't crash
-func T /* ERROR missing */ [P] /* ERROR missing */ m /* ERROR unexpected */ () /* ERROR \) */ { /* ERROR { */ } /* ERROR } */
+func T /* ERROR "missing" */ [P] /* ERROR "missing" */ m /* ERROR "unexpected" */ () /* ERROR "\)" */ { /* ERROR "{" */ } /* ERROR "}" */
indices = indices[:0]
for i, want := range errList {
pattern := strings.TrimSpace(want.text[len(" ERROR "):])
+ // We expect all patterns to be quoted in double quotes
+ // and then we remove the quotes.
+ // TODO(gri) use correct strconv.Unquote eventually
if n := len(pattern); n >= 2 && pattern[0] == '"' && pattern[n-1] == '"' {
pattern = pattern[1 : n-1]
+ } else {
+ t.Errorf("%s:%d:%d: unquoted pattern: %s", filename, line, want.col, pattern)
+ continue
}
rx, err := regexp.Compile(pattern)
if err != nil {
}
func TestLongConstants(t *testing.T) {
- format := "package longconst\n\nconst _ = %s /* ERROR constant overflow */ \nconst _ = %s // ERROR excessively long constant"
+ format := `package longconst; const _ = %s /* ERROR "constant overflow" */; const _ = %s // ERROR "excessively long constant"`
src := fmt.Sprintf(format, strings.Repeat("1", 9999), strings.Repeat("1", 10001))
testFiles(t, nil, []string{"longconst.go"}, [][]byte{[]byte(src)}, false, nil)
}
// be representable as int even if they already have a type that can
// represent larger values.
func TestIndexRepresentability(t *testing.T) {
- const src = "package index\n\nvar s []byte\nvar _ = s[int64 /* ERROR \"int64\\(1\\) << 40 \\(.*\\) overflows int\" */ (1) << 40]"
+ const src = `package index; var s []byte; var _ = s[int64 /* ERROR "int64\(1\) << 40 \(.*\) overflows int" */ (1) << 40]`
testFiles(t, &StdSizes{4, 4}, []string{"index.go"}, [][]byte{[]byte(src)}, false, nil)
}
func TestIssue47243_TypedRHS(t *testing.T) {
// The RHS of the shift expression below overflows uint on 32bit platforms,
// but this is OK as it is explicitly typed.
- const src = "package issue47243\n\nvar a uint64; var _ = a << uint64(4294967296)" // uint64(1<<32)
+ const src = `package issue47243; var a uint64; var _ = a << uint64(4294967296)` // uint64(1<<32)
testFiles(t, &StdSizes{4, 4}, []string{"p.go"}, [][]byte{[]byte(src)}, false, nil)
}
func _() {
// Packages should be fully qualified when there is ambiguity within the
// error string itself.
- a.F(template /* ERROR cannot use.*html/template.* as .*text/template */ .Template{})
+ a.F(template /* ERROR "cannot use.*html/template.* as .*text/template" */ .Template{})
}
`
csrc = `
)
// Issue #46905: make sure template is not the first package qualified.
-var _ fmt.Stringer = 1 // ERROR cannot use 1.*as fmt\.Stringer
+var _ fmt.Stringer = 1 // ERROR "cannot use 1.*as fmt\.Stringer"
// Packages should be fully qualified when there is ambiguity in reachable
// packages. In this case both a (and for that matter html/template) import
// text/template.
-func _() { a.G(template /* ERROR cannot use .*html/template.*Template */ .Template{}) }
+func _() { a.G(template /* ERROR "cannot use .*html/template.*Template" */ .Template{}) }
`
tsrc = `
type T int
// Verify that the current package name also causes disambiguation.
-var _ T = template /* ERROR cannot use.*text/template.* as T value */.Template{}
+var _ T = template /* ERROR "cannot use.*text/template.* as T value" */.Template{}
`
)
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package _ /* ERROR invalid package name */
+package _ /* ERROR "invalid package name" */
var b byte
var x int
var s []byte
- _ = append() // ERROR not enough arguments
- _ = append("foo" /* ERROR must be a slice */ )
- _ = append(nil /* ERROR must be a slice */ , s)
- _ = append(x /* ERROR must be a slice */ , s)
+ _ = append() // ERROR "not enough arguments"
+ _ = append("foo" /* ERROR "must be a slice" */ )
+ _ = append(nil /* ERROR "must be a slice" */ , s)
+ _ = append(x /* ERROR "must be a slice" */ , s)
_ = append(s)
_ = append(s, nil...)
- append /* ERROR not used */ (s)
+ append /* ERROR "not used" */ (s)
_ = append(s, b)
- _ = append(s, x /* ERROR cannot use x */ )
- _ = append(s, s /* ERROR cannot use s */ )
- _ = append(s...) /* ERROR not enough arguments */
- _ = append(s, b, s /* ERROR too many arguments */ ...)
+ _ = append(s, x /* ERROR "cannot use x" */ )
+ _ = append(s, s /* ERROR "cannot use s" */ )
+ _ = append(s...) /* ERROR "not enough arguments" */
+ _ = append(s, b, s /* ERROR "too many arguments" */ ...)
_ = append(s, 1, 2, 3)
- _ = append(s, 1, 2, 3, x /* ERROR cannot use x */ , 5, 6, 6)
- _ = append(s, 1, 2 /* ERROR too many arguments */, s...)
+ _ = append(s, 1, 2, 3, x /* ERROR "cannot use x" */ , 5, 6, 6)
+ _ = append(s, 1, 2 /* ERROR "too many arguments" */, s...)
_ = append([]interface{}(nil), 1, 2, "foo", x, 3.1425, false)
type S []byte
type T string
var t T
- _ = append(s, "foo" /* ERROR cannot use .* in argument to append */ )
+ _ = append(s, "foo" /* ERROR "cannot use .* in argument to append" */ )
_ = append(s, "foo"...)
- _ = append(S(s), "foo" /* ERROR cannot use .* in argument to append */ )
+ _ = append(S(s), "foo" /* ERROR "cannot use .* in argument to append" */ )
_ = append(S(s), "foo"...)
- _ = append(s, t /* ERROR cannot use t */ )
+ _ = append(s, t /* ERROR "cannot use t" */ )
_ = append(s, t...)
_ = append(s, T("foo")...)
- _ = append(S(s), t /* ERROR cannot use t */ )
+ _ = append(S(s), t /* ERROR "cannot use t" */ )
_ = append(S(s), t...)
_ = append(S(s), T("foo")...)
- _ = append([]string{}, t /* ERROR cannot use t */ , "foo")
+ _ = append([]string{}, t /* ERROR "cannot use t" */ , "foo")
_ = append([]T{}, t, "foo")
}
f3 := func() (s []int, x, y int) { return }
f5 := func() (s []interface{}, x int, y float32, z string, b bool) { return }
ff := func() (int, float32) { return 0, 0 }
- _ = append(f0 /* ERROR used as value */ ())
+ _ = append(f0 /* ERROR "used as value" */ ())
_ = append(f1())
_ = append(f2())
_ = append(f3())
_ = append(f5())
- _ = append(ff /* ERROR must be a slice */ ()) // TODO(gri) better error message
+ _ = append(ff /* ERROR "must be a slice" */ ()) // TODO(gri) better error message
}
func cap1() {
var a [10]bool
var p *[20]int
var c chan string
- _ = cap() // ERROR not enough arguments
- _ = cap(1, 2) // ERROR too many arguments
- _ = cap(42 /* ERROR invalid */)
+ _ = cap() // ERROR "not enough arguments"
+ _ = cap(1, 2) // ERROR "too many arguments"
+ _ = cap(42 /* ERROR "invalid" */)
const _3 = cap(a)
assert(_3 == 10)
const _4 = cap(p)
assert(_4 == 20)
_ = cap(c)
- cap /* ERROR not used */ (c)
+ cap /* ERROR "not used" */ (c)
// issue 4744
type T struct{ a [10]int }
var s [][]byte
_ = cap(s)
- _ = cap(s... /* ERROR invalid use of \.\.\. */ )
+ _ = cap(s... /* ERROR "invalid use of \.\.\." */ )
}
func cap2() {
f1a := func() (a [10]int) { return }
f1s := func() (s []int) { return }
f2 := func() (s []int, x int) { return }
- _ = cap(f0 /* ERROR used as value */ ())
+ _ = cap(f0 /* ERROR "used as value" */ ())
_ = cap(f1a())
_ = cap(f1s())
- _ = cap(f2()) // ERROR too many arguments
+ _ = cap(f2()) // ERROR "too many arguments"
}
// test cases for issue 7387
const (
_ = cap([4]int{})
_ = cap([4]int{x})
- _ = cap /* ERROR not constant */ ([4]int{f()})
- _ = cap /* ERROR not constant */ ([4]int{cap([]int{})})
+ _ = cap /* ERROR "not constant" */ ([4]int{f()})
+ _ = cap /* ERROR "not constant" */ ([4]int{cap([]int{})})
_ = cap([4]int{cap([4]int{})})
)
var y float64
_ = cap([4]float64{})
_ = cap([4]float64{y})
_ = cap([4]float64{real(2i)})
- _ = cap /* ERROR not constant */ ([4]float64{real(z)})
+ _ = cap /* ERROR "not constant" */ ([4]float64{real(z)})
)
var ch chan [10]int
const (
- _ = cap /* ERROR not constant */ (<-ch)
- _ = cap /* ERROR not constant */ ([4]int{(<-ch)[0]})
+ _ = cap /* ERROR "not constant" */ (<-ch)
+ _ = cap /* ERROR "not constant" */ ([4]int{(<-ch)[0]})
)
}
var a [10]int
var m map[float64]string
var s []byte
- clear(a /* ERROR cannot clear a */)
+ clear(a /* ERROR "cannot clear a" */)
clear(&a)
clear(m)
clear(s)
func close1() {
var c chan int
var r <-chan int
- close() // ERROR not enough arguments
- close(1, 2) // ERROR too many arguments
- close(42 /* ERROR cannot close non-channel */)
- close(r /* ERROR receive-only channel */)
+ close() // ERROR "not enough arguments"
+ close(1, 2) // ERROR "too many arguments"
+ close(42 /* ERROR "cannot close non-channel" */)
+ close(r /* ERROR "receive-only channel" */)
close(c)
- _ = close /* ERROR used as value */ (c)
+ _ = close /* ERROR "used as value" */ (c)
var s []chan int
- close(s... /* ERROR invalid use of \.\.\. */ )
+ close(s... /* ERROR "invalid use of \.\.\." */ )
}
func close2() {
f1 := func() (ch chan int) { return }
f2 := func() (ch chan int, x int) { return }
- close(f0 /* ERROR used as value */ ())
+ close(f0 /* ERROR "used as value" */ ())
close(f1())
- close(f2()) // ERROR too many arguments
+ close(f2()) // ERROR "too many arguments"
}
func complex1() {
var f64 float64
var c64 complex64
var c128 complex128
- _ = complex() // ERROR not enough arguments
- _ = complex(1) // ERROR not enough arguments
- _ = complex(true /* ERROR mismatched types */ , 0)
- _ = complex(i32 /* ERROR expected floating-point */ , 0)
- _ = complex("foo" /* ERROR mismatched types */ , 0)
- _ = complex(c64 /* ERROR expected floating-point */ , 0)
- _ = complex(0 /* ERROR mismatched types */ , true)
- _ = complex(0 /* ERROR expected floating-point */ , i32)
- _ = complex(0 /* ERROR mismatched types */ , "foo")
- _ = complex(0 /* ERROR expected floating-point */ , c64)
+ _ = complex() // ERROR "not enough arguments"
+ _ = complex(1) // ERROR "not enough arguments"
+ _ = complex(true /* ERROR "mismatched types" */ , 0)
+ _ = complex(i32 /* ERROR "expected floating-point" */ , 0)
+ _ = complex("foo" /* ERROR "mismatched types" */ , 0)
+ _ = complex(c64 /* ERROR "expected floating-point" */ , 0)
+ _ = complex(0 /* ERROR "mismatched types" */ , true)
+ _ = complex(0 /* ERROR "expected floating-point" */ , i32)
+ _ = complex(0 /* ERROR "mismatched types" */ , "foo")
+ _ = complex(0 /* ERROR "expected floating-point" */ , c64)
_ = complex(f32, f32)
_ = complex(f32, 1)
_ = complex(f32, 1.0)
_ = complex(f64, 1)
_ = complex(f64, 1.0)
_ = complex(f64, 'a')
- _ = complex(f32 /* ERROR mismatched types */ , f64)
- _ = complex(f64 /* ERROR mismatched types */ , f32)
+ _ = complex(f32 /* ERROR "mismatched types" */ , f64)
+ _ = complex(f64 /* ERROR "mismatched types" */ , f32)
_ = complex(1, 1)
_ = complex(1, 1.1)
_ = complex(1, 'a')
- complex /* ERROR not used */ (1, 2)
+ complex /* ERROR "not used" */ (1, 2)
var _ complex64 = complex(f32, f32)
- var _ complex64 = complex /* ERROR cannot use .* in variable declaration */ (f64, f64)
+ var _ complex64 = complex /* ERROR "cannot use .* in variable declaration" */ (f64, f64)
- var _ complex128 = complex /* ERROR cannot use .* in variable declaration */ (f32, f32)
+ var _ complex128 = complex /* ERROR "cannot use .* in variable declaration" */ (f32, f32)
var _ complex128 = complex(f64, f64)
// untyped constants
const _ = complex(0i, 0)
const _ int = 1.0 + complex(1, 0i)
- const _ int = complex /* ERROR int */ (1.1, 0)
- const _ float32 = complex /* ERROR float32 */ (1, 2)
+ const _ int = complex /* ERROR "int" */ (1.1, 0)
+ const _ float32 = complex /* ERROR "float32" */ (1, 2)
// untyped values
var s uint
- _ = complex(1 /* ERROR integer */ <<s, 0)
- const _ = complex /* ERROR not constant */ (1 /* ERROR integer */ <<s, 0)
- var _ int = complex /* ERROR cannot use .* in variable declaration */ (1 /* ERROR integer */ <<s, 0)
+ _ = complex(1 /* ERROR "integer" */ <<s, 0)
+ const _ = complex /* ERROR "not constant" */ (1 /* ERROR "integer" */ <<s, 0)
+ var _ int = complex /* ERROR "cannot use .* in variable declaration" */ (1 /* ERROR "integer" */ <<s, 0)
// floating-point argument types must be identical
type F32 float32
var x32 F32
var x64 F64
c64 = complex(x32, x32)
- _ = complex(x32 /* ERROR mismatched types */ , f32)
- _ = complex(f32 /* ERROR mismatched types */ , x32)
+ _ = complex(x32 /* ERROR "mismatched types" */ , f32)
+ _ = complex(f32 /* ERROR "mismatched types" */ , x32)
c128 = complex(x64, x64)
_ = c128
- _ = complex(x64 /* ERROR mismatched types */ , f64)
- _ = complex(f64 /* ERROR mismatched types */ , x64)
+ _ = complex(x64 /* ERROR "mismatched types" */ , f64)
+ _ = complex(f64 /* ERROR "mismatched types" */ , x64)
var t []float32
- _ = complex(t... /* ERROR invalid use of \.\.\. */ )
+ _ = complex(t... /* ERROR "invalid use of \.\.\." */ )
}
func complex2() {
f1 := func() (x float32) { return }
f2 := func() (x, y float32) { return }
f3 := func() (x, y, z float32) { return }
- _ = complex(f0 /* ERROR used as value */ ())
- _ = complex(f1()) // ERROR not enough arguments
+ _ = complex(f0 /* ERROR "used as value" */ ())
+ _ = complex(f1()) // ERROR "not enough arguments"
_ = complex(f2())
- _ = complex(f3()) // ERROR too many arguments
+ _ = complex(f3()) // ERROR "too many arguments"
}
func copy1() {
- copy() // ERROR not enough arguments
- copy("foo") // ERROR not enough arguments
- copy([ /* ERROR copy expects slice arguments */ ...]int{}, []int{})
- copy([ /* ERROR copy expects slice arguments */ ]int{}, [...]int{})
- copy([ /* ERROR different element types */ ]int8{}, "foo")
+ copy() // ERROR "not enough arguments"
+ copy("foo") // ERROR "not enough arguments"
+ copy([ /* ERROR "copy expects slice arguments" */ ...]int{}, []int{})
+ copy([ /* ERROR "copy expects slice arguments" */ ]int{}, [...]int{})
+ copy([ /* ERROR "different element types" */ ]int8{}, "foo")
// spec examples
var a = [...]int{0, 1, 2, 3, 4, 5, 6, 7}
var t [][]int
copy(t, t)
- copy(t /* ERROR copy expects slice arguments */ , nil)
- copy(nil /* ERROR copy expects slice arguments */ , t)
- copy(nil /* ERROR copy expects slice arguments */ , nil)
- copy(t... /* ERROR invalid use of \.\.\. */ )
+ copy(t /* ERROR "copy expects slice arguments" */ , nil)
+ copy(nil /* ERROR "copy expects slice arguments" */ , t)
+ copy(nil /* ERROR "copy expects slice arguments" */ , nil)
+ copy(t... /* ERROR "invalid use of \.\.\." */ )
}
func copy2() {
f1 := func() (a []int) { return }
f2 := func() (a, b []int) { return }
f3 := func() (a, b, c []int) { return }
- copy(f0 /* ERROR used as value */ ())
- copy(f1()) // ERROR not enough arguments
+ copy(f0 /* ERROR "used as value" */ ())
+ copy(f1()) // ERROR "not enough arguments"
copy(f2())
- copy(f3()) // ERROR too many arguments
+ copy(f3()) // ERROR "too many arguments"
}
func delete1() {
var m map[string]int
var s string
- delete() // ERROR not enough arguments
- delete(1) // ERROR not enough arguments
- delete(1, 2, 3) // ERROR too many arguments
- delete(m, 0 /* ERROR cannot use */)
+ delete() // ERROR "not enough arguments"
+ delete(1) // ERROR "not enough arguments"
+ delete(1, 2, 3) // ERROR "too many arguments"
+ delete(m, 0 /* ERROR "cannot use" */)
delete(m, s)
- _ = delete /* ERROR used as value */ (m, s)
+ _ = delete /* ERROR "used as value" */ (m, s)
var t []map[string]string
- delete(t... /* ERROR invalid use of \.\.\. */ )
+ delete(t... /* ERROR "invalid use of \.\.\." */ )
}
func delete2() {
f1 := func() (m map[string]int) { return }
f2 := func() (m map[string]int, k string) { return }
f3 := func() (m map[string]int, k string, x float32) { return }
- delete(f0 /* ERROR used as value */ ())
- delete(f1()) // ERROR not enough arguments
+ delete(f0 /* ERROR "used as value" */ ())
+ delete(f1()) // ERROR "not enough arguments"
delete(f2())
- delete(f3()) // ERROR too many arguments
+ delete(f3()) // ERROR "too many arguments"
}
func imag1() {
var f64 float64
var c64 complex64
var c128 complex128
- _ = imag() // ERROR not enough arguments
- _ = imag(1, 2) // ERROR too many arguments
+ _ = imag() // ERROR "not enough arguments"
+ _ = imag(1, 2) // ERROR "too many arguments"
_ = imag(10)
_ = imag(2.7182818)
- _ = imag("foo" /* ERROR expected complex */)
+ _ = imag("foo" /* ERROR "expected complex" */)
_ = imag('a')
const _5 = imag(1 + 2i)
assert(_5 == 2)
assert(_6 == 0)
f32 = imag(c64)
f64 = imag(c128)
- f32 = imag /* ERROR cannot use .* in assignment */ (c128)
- f64 = imag /* ERROR cannot use .* in assignment */ (c64)
- imag /* ERROR not used */ (c64)
+ f32 = imag /* ERROR "cannot use .* in assignment" */ (c128)
+ f64 = imag /* ERROR "cannot use .* in assignment" */ (c64)
+ imag /* ERROR "not used" */ (c64)
_, _ = f32, f64
// complex type may not be predeclared
f64 = imag(x128)
var a []complex64
- _ = imag(a... /* ERROR invalid use of \.\.\. */ )
+ _ = imag(a... /* ERROR "invalid use of \.\.\." */ )
// if argument is untyped, result is untyped
const _ byte = imag(1.2 + 3i)
// lhs constant shift operands are typed as complex128
var s uint
- _ = imag(1 /* ERROR must be integer */ << s)
+ _ = imag(1 /* ERROR "must be integer" */ << s)
}
func imag2() {
f1 := func() (x complex128) { return }
f2 := func() (x, y complex128) { return }
- _ = imag(f0 /* ERROR used as value */ ())
+ _ = imag(f0 /* ERROR "used as value" */ ())
_ = imag(f1())
- _ = imag(f2()) // ERROR too many arguments
+ _ = imag(f2()) // ERROR "too many arguments"
}
func len1() {
var a [10]bool
var p *[20]int
var m map[string]complex128
- _ = len() // ERROR not enough arguments
- _ = len(1, 2) // ERROR too many arguments
- _ = len(42 /* ERROR invalid */)
+ _ = len() // ERROR "not enough arguments"
+ _ = len(1, 2) // ERROR "too many arguments"
+ _ = len(42 /* ERROR "invalid" */)
const _3 = len(c)
assert(_3 == 6)
const _4 = len(a)
const _5 = len(p)
assert(_5 == 20)
_ = len(m)
- len /* ERROR not used */ (c)
+ len /* ERROR "not used" */ (c)
// esoteric case
var t string
var hash map[interface{}][]*[10]int
- const n = len /* ERROR not constant */ (hash[recover()][len(t)])
+ const n = len /* ERROR "not constant" */ (hash[recover()][len(t)])
assert(n == 10) // ok because n has unknown value and no error is reported
var ch <-chan int
- const nn = len /* ERROR not constant */ (hash[<-ch][len(t)])
+ const nn = len /* ERROR "not constant" */ (hash[<-ch][len(t)])
// issue 4744
type T struct{ a [10]int }
var s [][]byte
_ = len(s)
- _ = len(s... /* ERROR invalid use of \.\.\. */ )
+ _ = len(s... /* ERROR "invalid use of \.\.\." */ )
}
func len2() {
f1 := func() (x []int) { return }
f2 := func() (x, y []int) { return }
- _ = len(f0 /* ERROR used as value */ ())
+ _ = len(f0 /* ERROR "used as value" */ ())
_ = len(f1())
- _ = len(f2()) // ERROR too many arguments
+ _ = len(f2()) // ERROR "too many arguments"
}
// test cases for issue 7387
const (
_ = len([4]int{})
_ = len([4]int{x})
- _ = len /* ERROR not constant */ ([4]int{f()})
- _ = len /* ERROR not constant */ ([4]int{len([]int{})})
+ _ = len /* ERROR "not constant" */ ([4]int{f()})
+ _ = len /* ERROR "not constant" */ ([4]int{len([]int{})})
_ = len([4]int{len([4]int{})})
)
var y float64
_ = len([4]float64{})
_ = len([4]float64{y})
_ = len([4]float64{real(2i)})
- _ = len /* ERROR not constant */ ([4]float64{real(z)})
+ _ = len /* ERROR "not constant" */ ([4]float64{real(z)})
)
var ch chan [10]int
const (
- _ = len /* ERROR not constant */ (<-ch)
- _ = len /* ERROR not constant */ ([4]int{(<-ch)[0]})
+ _ = len /* ERROR "not constant" */ (<-ch)
+ _ = len /* ERROR "not constant" */ ([4]int{(<-ch)[0]})
)
}
var m float32
var s uint
- _ = make() // ERROR not enough arguments
- _ = make(1 /* ERROR not a type */)
- _ = make(int /* ERROR cannot make */)
+ _ = make() // ERROR "not enough arguments"
+ _ = make(1 /* ERROR "not a type" */)
+ _ = make(int /* ERROR "cannot make" */)
// slices
- _ = make/* ERROR arguments */ ([]int)
- _ = make/* ERROR arguments */ ([]int, 2, 3, 4)
- _ = make([]int, int /* ERROR not an expression */)
- _ = make([]int, 10, float32 /* ERROR not an expression */)
- _ = make([]int, "foo" /* ERROR cannot convert */)
- _ = make([]int, 10, 2.3 /* ERROR truncated */)
+ _ = make/* ERROR "arguments" */ ([]int)
+ _ = make/* ERROR "arguments" */ ([]int, 2, 3, 4)
+ _ = make([]int, int /* ERROR "not an expression" */)
+ _ = make([]int, 10, float32 /* ERROR "not an expression" */)
+ _ = make([]int, "foo" /* ERROR "cannot convert" */)
+ _ = make([]int, 10, 2.3 /* ERROR "truncated" */)
_ = make([]int, 5, 10.0)
_ = make([]int, 0i)
_ = make([]int, 1.0)
_ = make([]int, 1.0<<s)
- _ = make([]int, 1.1 /* ERROR int */ <<s)
- _ = make([]int, - /* ERROR must not be negative */ 1, 10)
- _ = make([]int, 0, - /* ERROR must not be negative */ 1)
- _ = make([]int, - /* ERROR must not be negative */ 1, - /* ERROR must not be negative */ 1)
- _ = make([]int, 1 /* ERROR overflows */ <<100, 1 /* ERROR overflows */ <<100)
- _ = make([]int, 10 /* ERROR length and capacity swapped */ , 9)
- _ = make([]int, 1 /* ERROR overflows */ <<100, 12345)
- _ = make([]int, m /* ERROR must be integer */ )
- _ = &make /* ERROR cannot take address */ ([]int, 0)
+ _ = make([]int, 1.1 /* ERROR "int" */ <<s)
+ _ = make([]int, - /* ERROR "must not be negative" */ 1, 10)
+ _ = make([]int, 0, - /* ERROR "must not be negative" */ 1)
+ _ = make([]int, - /* ERROR "must not be negative" */ 1, - /* ERROR "must not be negative" */ 1)
+ _ = make([]int, 1 /* ERROR "overflows" */ <<100, 1 /* ERROR "overflows" */ <<100)
+ _ = make([]int, 10 /* ERROR "length and capacity swapped" */ , 9)
+ _ = make([]int, 1 /* ERROR "overflows" */ <<100, 12345)
+ _ = make([]int, m /* ERROR "must be integer" */ )
+ _ = &make /* ERROR "cannot take address" */ ([]int, 0)
// maps
- _ = make /* ERROR arguments */ (map[int]string, 10, 20)
- _ = make(map[int]float32, int /* ERROR not an expression */)
- _ = make(map[int]float32, "foo" /* ERROR cannot convert */)
+ _ = make /* ERROR "arguments" */ (map[int]string, 10, 20)
+ _ = make(map[int]float32, int /* ERROR "not an expression" */)
+ _ = make(map[int]float32, "foo" /* ERROR "cannot convert" */)
_ = make(map[int]float32, 10)
_ = make(map[int]float32, n)
_ = make(map[int]float32, int64(n))
_ = make(map[string]bool, 10.0)
_ = make(map[string]bool, 10.0<<s)
- _ = &make /* ERROR cannot take address */ (map[string]bool)
+ _ = &make /* ERROR "cannot take address" */ (map[string]bool)
// channels
- _ = make /* ERROR arguments */ (chan int, 10, 20)
- _ = make(chan int, int /* ERROR not an expression */)
- _ = make(chan<- int, "foo" /* ERROR cannot convert */)
- _ = make(chan int, - /* ERROR must not be negative */ 10)
+ _ = make /* ERROR "arguments" */ (chan int, 10, 20)
+ _ = make(chan int, int /* ERROR "not an expression" */)
+ _ = make(chan<- int, "foo" /* ERROR "cannot convert" */)
+ _ = make(chan int, - /* ERROR "must not be negative" */ 10)
_ = make(<-chan float64, 10)
_ = make(chan chan int, n)
_ = make(chan string, int64(n))
_ = make(chan bool, 10.0)
_ = make(chan bool, 10.0<<s)
- _ = &make /* ERROR cannot take address */ (chan bool)
+ _ = &make /* ERROR "cannot take address" */ (chan bool)
- make /* ERROR not used */ ([]int, 10)
+ make /* ERROR "not used" */ ([]int, 10)
var t []int
_ = make([]int, t[0], t[1])
- _ = make([]int, t... /* ERROR invalid use of \.\.\. */ )
+ _ = make([]int, t... /* ERROR "invalid use of \.\.\." */ )
}
func make2() {
f1 := func() (x []int) { return }
- _ = make(f0 /* ERROR not a type */ ())
- _ = make(f1 /* ERROR not a type */ ())
+ _ = make(f0 /* ERROR "not a type" */ ())
+ _ = make(f1 /* ERROR "not a type" */ ())
}
func new1() {
- _ = new() // ERROR not enough arguments
- _ = new(1, 2) // ERROR too many arguments
- _ = new("foo" /* ERROR not a type */)
+ _ = new() // ERROR "not enough arguments"
+ _ = new(1, 2) // ERROR "too many arguments"
+ _ = new("foo" /* ERROR "not a type" */)
p := new(float64)
_ = new(struct{ x, y int })
q := new(*float64)
_ = *p == **q
- new /* ERROR not used */ (int)
- _ = &new /* ERROR cannot take address */ (int)
+ new /* ERROR "not used" */ (int)
+ _ = &new /* ERROR "cannot take address" */ (int)
- _ = new(int... /* ERROR invalid use of \.\.\. */ )
+ _ = new(int... /* ERROR "invalid use of \.\.\." */ )
}
func new2() {
f1 := func() (x []int) { return }
- _ = new(f0 /* ERROR not a type */ ())
- _ = new(f1 /* ERROR not a type */ ())
+ _ = new(f0 /* ERROR "not a type" */ ())
+ _ = new(f1 /* ERROR "not a type" */ ())
}
func panic1() {
- panic() // ERROR not enough arguments
- panic(1, 2) // ERROR too many arguments
+ panic() // ERROR "not enough arguments"
+ panic(1, 2) // ERROR "too many arguments"
panic(0)
panic("foo")
panic(false)
panic(1<<10)
- panic(1 << /* ERROR constant shift overflow */ 1000)
- _ = panic /* ERROR used as value */ (0)
+ panic(1 << /* ERROR "constant shift overflow" */ 1000)
+ _ = panic /* ERROR "used as value" */ (0)
var s []byte
panic(s)
- panic(s... /* ERROR invalid use of \.\.\. */ )
+ panic(s... /* ERROR "invalid use of \.\.\." */ )
}
func panic2() {
f1 := func() (x int) { return }
f2 := func() (x, y int) { return }
- panic(f0 /* ERROR used as value */ ())
+ panic(f0 /* ERROR "used as value" */ ())
panic(f1())
- panic(f2()) // ERROR too many arguments
+ panic(f2()) // ERROR "too many arguments"
}
func print1() {
print(2.718281828)
print(false)
print(1<<10)
- print(1 << /* ERROR constant shift overflow */ 1000)
- println(nil /* ERROR untyped nil */ )
+ print(1 << /* ERROR "constant shift overflow" */ 1000)
+ println(nil /* ERROR "untyped nil" */ )
var s []int
- print(s... /* ERROR invalid use of \.\.\. */ )
- _ = print /* ERROR used as value */ ()
+ print(s... /* ERROR "invalid use of \.\.\." */ )
+ _ = print /* ERROR "used as value" */ ()
}
func print2() {
f1 := func() (x int) { return }
f2 := func() (x, y int) { return }
f3 := func() (x int, y float32, z string) { return }
- print(f0 /* ERROR used as value */ ())
+ print(f0 /* ERROR "used as value" */ ())
print(f1())
print(f2())
print(f3())
println(2.718281828)
println(false)
println(1<<10)
- println(1 << /* ERROR constant shift overflow */ 1000)
- println(nil /* ERROR untyped nil */ )
+ println(1 << /* ERROR "constant shift overflow" */ 1000)
+ println(nil /* ERROR "untyped nil" */ )
var s []int
- println(s... /* ERROR invalid use of \.\.\. */ )
- _ = println /* ERROR used as value */ ()
+ println(s... /* ERROR "invalid use of \.\.\." */ )
+ _ = println /* ERROR "used as value" */ ()
}
func println2() {
f1 := func() (x int) { return }
f2 := func() (x, y int) { return }
f3 := func() (x int, y float32, z string) { return }
- println(f0 /* ERROR used as value */ ())
+ println(f0 /* ERROR "used as value" */ ())
println(f1())
println(f2())
println(f3())
var f64 float64
var c64 complex64
var c128 complex128
- _ = real() // ERROR not enough arguments
- _ = real(1, 2) // ERROR too many arguments
+ _ = real() // ERROR "not enough arguments"
+ _ = real(1, 2) // ERROR "too many arguments"
_ = real(10)
_ = real(2.7182818)
- _ = real("foo" /* ERROR expected complex */)
+ _ = real("foo" /* ERROR "expected complex" */)
const _5 = real(1 + 2i)
assert(_5 == 1)
f32 = _5
assert(_6 == 0)
f32 = real(c64)
f64 = real(c128)
- f32 = real /* ERROR cannot use .* in assignment */ (c128)
- f64 = real /* ERROR cannot use .* in assignment */ (c64)
- real /* ERROR not used */ (c64)
+ f32 = real /* ERROR "cannot use .* in assignment" */ (c128)
+ f64 = real /* ERROR "cannot use .* in assignment" */ (c64)
+ real /* ERROR "not used" */ (c64)
// complex type may not be predeclared
type C64 complex64
_, _ = f32, f64
var a []complex64
- _ = real(a... /* ERROR invalid use of \.\.\. */ )
+ _ = real(a... /* ERROR "invalid use of \.\.\." */ )
// if argument is untyped, result is untyped
const _ byte = real(1 + 2.3i)
// lhs constant shift operands are typed as complex128
var s uint
- _ = real(1 /* ERROR must be integer */ << s)
+ _ = real(1 /* ERROR "must be integer" */ << s)
}
func real2() {
f1 := func() (x complex128) { return }
f2 := func() (x, y complex128) { return }
- _ = real(f0 /* ERROR used as value */ ())
+ _ = real(f0 /* ERROR "used as value" */ ())
_ = real(f1())
- _ = real(f2()) // ERROR too many arguments
+ _ = real(f2()) // ERROR "too many arguments"
}
func recover1() {
_ = recover()
- _ = recover(10) // ERROR too many arguments
+ _ = recover(10) // ERROR "too many arguments"
recover()
var s []int
- recover(s... /* ERROR invalid use of \.\.\. */ )
+ recover(s... /* ERROR "invalid use of \.\.\." */ )
}
func recover2() {
f1 := func() (x int) { return }
f2 := func() (x, y int) { return }
- _ = recover(f0 /* ERROR used as value */ ())
- _ = recover(f1()) // ERROR too many arguments
- _ = recover(f2()) // ERROR too many arguments
+ _ = recover(f0 /* ERROR "used as value" */ ())
+ _ = recover(f1()) // ERROR "too many arguments"
+ _ = recover(f2()) // ERROR "too many arguments"
}
// assuming types.DefaultPtrSize == 8
func Alignof1() {
var x int
- _ = unsafe.Alignof() // ERROR not enough arguments
- _ = unsafe.Alignof(1, 2) // ERROR too many arguments
- _ = unsafe.Alignof(int /* ERROR not an expression */)
+ _ = unsafe.Alignof() // ERROR "not enough arguments"
+ _ = unsafe.Alignof(1, 2) // ERROR "too many arguments"
+ _ = unsafe.Alignof(int /* ERROR "not an expression" */)
_ = unsafe.Alignof(42)
_ = unsafe.Alignof(new(struct{}))
_ = unsafe.Alignof(1<<10)
- _ = unsafe.Alignof(1 << /* ERROR constant shift overflow */ 1000)
- _ = unsafe.Alignof(nil /* ERROR untyped nil */ )
- unsafe /* ERROR not used */ .Alignof(x)
+ _ = unsafe.Alignof(1 << /* ERROR "constant shift overflow" */ 1000)
+ _ = unsafe.Alignof(nil /* ERROR "untyped nil" */ )
+ unsafe /* ERROR "not used" */ .Alignof(x)
var y S0
assert(unsafe.Alignof(y.a) == 1)
var s []byte
_ = unsafe.Alignof(s)
- _ = unsafe.Alignof(s... /* ERROR invalid use of \.\.\. */ )
+ _ = unsafe.Alignof(s... /* ERROR "invalid use of \.\.\." */ )
}
func Alignof2() {
f1 := func() (x int32) { return }
f2 := func() (x, y int32) { return }
- _ = unsafe.Alignof(f0 /* ERROR used as value */ ())
+ _ = unsafe.Alignof(f0 /* ERROR "used as value" */ ())
assert(unsafe.Alignof(f1()) == 4)
- _ = unsafe.Alignof(f2()) // ERROR too many arguments
+ _ = unsafe.Alignof(f2()) // ERROR "too many arguments"
}
func Offsetof1() {
var x struct{ f int }
- _ = unsafe.Offsetof() // ERROR not enough arguments
- _ = unsafe.Offsetof(1, 2) // ERROR too many arguments
- _ = unsafe.Offsetof(int /* ERROR not a selector expression */ )
- _ = unsafe.Offsetof(x /* ERROR not a selector expression */ )
- _ = unsafe.Offsetof(nil /* ERROR not a selector expression */ )
+ _ = unsafe.Offsetof() // ERROR "not enough arguments"
+ _ = unsafe.Offsetof(1, 2) // ERROR "too many arguments"
+ _ = unsafe.Offsetof(int /* ERROR "not a selector expression" */ )
+ _ = unsafe.Offsetof(x /* ERROR "not a selector expression" */ )
+ _ = unsafe.Offsetof(nil /* ERROR "not a selector expression" */ )
_ = unsafe.Offsetof(x.f)
_ = unsafe.Offsetof((x.f))
_ = unsafe.Offsetof((((((((x))).f)))))
- unsafe /* ERROR not used */ .Offsetof(x.f)
+ unsafe /* ERROR "not used" */ .Offsetof(x.f)
var y0 S0
assert(unsafe.Offsetof(y0.a) == 0)
var y2 S2
assert(unsafe.Offsetof(y2.S1) == 0)
- _ = unsafe.Offsetof(y2 /* ERROR embedded via a pointer */ .x)
- _ = unsafe.Offsetof(y2 /* ERROR method value */ .m)
+ _ = unsafe.Offsetof(y2 /* ERROR "embedded via a pointer" */ .x)
+ _ = unsafe.Offsetof(y2 /* ERROR "method value" */ .m)
var s []byte
- _ = unsafe.Offsetof(s... /* ERROR invalid use of \.\.\. */ )
+ _ = unsafe.Offsetof(s... /* ERROR "invalid use of \.\.\." */ )
}
func Offsetof2() {
f1 := func() (x int32) { return }
f2 := func() (x, y int32) { return }
- _ = unsafe.Offsetof(f0 /* ERROR not a selector expression */ ())
- _ = unsafe.Offsetof(f1 /* ERROR not a selector expression */ ())
- _ = unsafe.Offsetof(f2 /* ERROR not a selector expression */ ())
+ _ = unsafe.Offsetof(f0 /* ERROR "not a selector expression" */ ())
+ _ = unsafe.Offsetof(f1 /* ERROR "not a selector expression" */ ())
+ _ = unsafe.Offsetof(f2 /* ERROR "not a selector expression" */ ())
}
func Sizeof1() {
var x int
- _ = unsafe.Sizeof() // ERROR not enough arguments
- _ = unsafe.Sizeof(1, 2) // ERROR too many arguments
- _ = unsafe.Sizeof(int /* ERROR not an expression */)
+ _ = unsafe.Sizeof() // ERROR "not enough arguments"
+ _ = unsafe.Sizeof(1, 2) // ERROR "too many arguments"
+ _ = unsafe.Sizeof(int /* ERROR "not an expression" */)
_ = unsafe.Sizeof(42)
_ = unsafe.Sizeof(new(complex128))
_ = unsafe.Sizeof(1<<10)
- _ = unsafe.Sizeof(1 << /* ERROR constant shift overflow */ 1000)
- _ = unsafe.Sizeof(nil /* ERROR untyped nil */ )
- unsafe /* ERROR not used */ .Sizeof(x)
+ _ = unsafe.Sizeof(1 << /* ERROR "constant shift overflow" */ 1000)
+ _ = unsafe.Sizeof(nil /* ERROR "untyped nil" */ )
+ unsafe /* ERROR "not used" */ .Sizeof(x)
// basic types have size guarantees
assert(unsafe.Sizeof(byte(0)) == 1)
var s []byte
_ = unsafe.Sizeof(s)
- _ = unsafe.Sizeof(s... /* ERROR invalid use of \.\.\. */ )
+ _ = unsafe.Sizeof(s... /* ERROR "invalid use of \.\.\." */ )
}
func Sizeof2() {
f1 := func() (x int64) { return }
f2 := func() (x, y int64) { return }
- _ = unsafe.Sizeof(f0 /* ERROR used as value */ ())
+ _ = unsafe.Sizeof(f0 /* ERROR "used as value" */ ())
assert(unsafe.Sizeof(f1()) == 8)
- _ = unsafe.Sizeof(f2()) // ERROR too many arguments
+ _ = unsafe.Sizeof(f2()) // ERROR "too many arguments"
}
func Slice1() {
var x int
- unsafe.Slice() // ERROR not enough arguments
- unsafe.Slice(1, 2, 3) // ERROR too many arguments
- unsafe.Slice(1 /* ERROR is not a pointer */ , 2)
- unsafe.Slice(nil /* ERROR nil is not a pointer */ , 0)
- unsafe.Slice(&x, "foo" /* ERROR cannot convert .* to type int */ )
- unsafe.Slice(&x, 1.2 /* ERROR truncated to int */ )
- unsafe.Slice(&x, - /* ERROR must not be negative */ 1)
- unsafe /* ERROR not used */ .Slice(&x, 0)
- var _ []byte = unsafe /* ERROR value of type \[\]int */ .Slice(&x, 0)
+ unsafe.Slice() // ERROR "not enough arguments"
+ unsafe.Slice(1, 2, 3) // ERROR "too many arguments"
+ unsafe.Slice(1 /* ERROR "is not a pointer" */ , 2)
+ unsafe.Slice(nil /* ERROR "nil is not a pointer" */ , 0)
+ unsafe.Slice(&x, "foo" /* ERROR "cannot convert .* to type int" */ )
+ unsafe.Slice(&x, 1.2 /* ERROR "truncated to int" */ )
+ unsafe.Slice(&x, - /* ERROR "must not be negative" */ 1)
+ unsafe /* ERROR "not used" */ .Slice(&x, 0)
+ var _ []byte = unsafe /* ERROR "value of type \[\]int" */ .Slice(&x, 0)
var _ []int = unsafe.Slice(&x, 0)
_ = unsafe.Slice(&x, 1.0)
func SliceData1() {
var s []int
- unsafe.SliceData(0 /* ERROR not a slice */)
- unsafe /* ERROR not used */ .SliceData(s)
+ unsafe.SliceData(0 /* ERROR "not a slice" */)
+ unsafe /* ERROR "not used" */ .SliceData(s)
type S []int
_ = unsafe.SliceData(s)
func String1() {
var b byte
- unsafe.String() // ERROR not enough arguments
- unsafe.String(1, 2, 3) // ERROR too many arguments
- unsafe.String(1 /* ERROR cannot use 1 */ , 2)
- unsafe.String(&b, "foo" /* ERROR cannot convert .* to type int */ )
- unsafe.String(&b, 1.2 /* ERROR truncated to int */ )
- unsafe.String(&b, - /* ERROR must not be negative */ 1)
- unsafe /* ERROR not used */ .String(&b, 0)
- var _ []byte = unsafe /* ERROR value of type string */ .String(&b, 0)
+ unsafe.String() // ERROR "not enough arguments"
+ unsafe.String(1, 2, 3) // ERROR "too many arguments"
+ unsafe.String(1 /* ERROR "cannot use 1" */ , 2)
+ unsafe.String(&b, "foo" /* ERROR "cannot convert .* to type int" */ )
+ unsafe.String(&b, 1.2 /* ERROR "truncated to int" */ )
+ unsafe.String(&b, - /* ERROR "must not be negative" */ 1)
+ unsafe /* ERROR "not used" */ .String(&b, 0)
+ var _ []byte = unsafe /* ERROR "value of type string" */ .String(&b, 0)
var _ string = unsafe.String(&b, 0)
_ = unsafe.String(&b, 1.0)
func StringData1() {
var s string
type S string
- unsafe.StringData(0 /* ERROR cannot use 0 */)
- unsafe.StringData(S /* ERROR cannot use S */ ("foo"))
- unsafe /* ERROR not used */ .StringData(s)
+ unsafe.StringData(0 /* ERROR "cannot use 0" */)
+ unsafe.StringData(S /* ERROR "cannot use S" */ ("foo"))
+ unsafe /* ERROR "not used" */ .StringData(s)
_ = unsafe.StringData(s)
_ = unsafe.StringData("foo")
// self-testing only
func assert1() {
var x int
- assert() /* ERROR not enough arguments */
- assert(1, 2) /* ERROR too many arguments */
- assert("foo" /* ERROR boolean constant */ )
- assert(x /* ERROR boolean constant */)
+ assert() /* ERROR "not enough arguments" */
+ assert(1, 2) /* ERROR "too many arguments" */
+ assert("foo" /* ERROR "boolean constant" */ )
+ assert(x /* ERROR "boolean constant" */)
assert(true)
- assert /* ERROR failed */ (false)
+ assert /* ERROR "failed" */ (false)
_ = assert(true)
var s []byte
- assert(s... /* ERROR invalid use of \.\.\. */ )
+ assert(s... /* ERROR "invalid use of \.\.\." */ )
}
func assert2() {
f1 := func() (x bool) { return }
f2 := func() (x bool) { return }
- assert(f0 /* ERROR used as value */ ())
- assert(f1 /* ERROR boolean constant */ ())
- assert(f2 /* ERROR boolean constant */ ())
+ assert(f0 /* ERROR "used as value" */ ())
+ assert(f1 /* ERROR "boolean constant" */ ())
+ assert(f2 /* ERROR "boolean constant" */ ())
}
// self-testing only
func trace1() {
// Uncomment the code below to test trace - will produce console output
- // _ = trace /* ERROR no value */ ()
+ // _ = trace /* ERROR "no value" */ ()
// _ = trace(1)
// _ = trace(true, 1.2, '\'', "foo", 42i, "foo" <= "bar")
var s []byte
- trace(s... /* ERROR invalid use of \.\.\. */ )
+ trace(s... /* ERROR "invalid use of \.\.\." */ )
}
func trace2() {
// clear
func _[T any](x T) {
- clear(x /* ERROR cannot clear x */)
+ clear(x /* ERROR "cannot clear x" */)
}
func _[T ~map[int]string | ~[]byte | ~*[10]int](x T) {
}
func _[T ~map[int]string | ~[]byte | ~*[10]int | string](x T) {
- clear(x /* ERROR cannot clear x */)
+ clear(x /* ERROR "cannot clear x" */)
}
// close
type C5[T any] interface{ ~chan T | chan<- T }
func _[T any](ch T) {
- close(ch /* ERROR cannot close non-channel */)
+ close(ch /* ERROR "cannot close non-channel" */)
}
func _[T C0](ch T) {
- close(ch /* ERROR cannot close non-channel */)
+ close(ch /* ERROR "cannot close non-channel" */)
}
func _[T C1](ch T) {
}
func _[T C2](ch T) {
- close(ch /* ERROR cannot close receive-only channel */)
+ close(ch /* ERROR "cannot close receive-only channel" */)
}
func _[T C3](ch T) {
// copy
func _[T any](x, y T) {
- copy(x /* ERROR copy expects slice arguments */ , y)
+ copy(x /* ERROR "copy expects slice arguments" */ , y)
}
func _[T ~[]byte](x, y T) {
copy(x, y)
copy(x, "foo")
- copy("foo" /* ERROR expects slice arguments */ , y)
+ copy("foo" /* ERROR "expects slice arguments" */ , y)
var x2 []byte
copy(x2, y) // element types are identical
type myByte byte
var x3 []myByte
- copy(x3 /* ERROR different element types */ , y)
- copy(y /* ERROR different element types */ , x3)
+ copy(x3 /* ERROR "different element types" */ , y)
+ copy(y /* ERROR "different element types" */ , x3)
}
func _[T ~[]E, E any](x T, y []E) {
copy(x, y)
- copy(x /* ERROR different element types */ , "foo")
+ copy(x /* ERROR "different element types" */ , "foo")
}
func _[T ~string](x []byte, y T) {
copy(x, y)
- copy(y /* ERROR expects slice arguments */ , x)
+ copy(y /* ERROR "expects slice arguments" */ , x)
}
func _[T ~[]byte|~string](x T, y []byte) {
- copy(x /* ERROR expects slice arguments */ , y)
+ copy(x /* ERROR "expects slice arguments" */ , y)
copy(y, x)
}
type M4[K comparable, V any] interface{ map[K]V | map[rune]V }
func _[T any](m T) {
- delete(m /* ERROR not a map */, "foo")
+ delete(m /* ERROR "not a map" */, "foo")
}
func _[T M0](m T) {
- delete(m /* ERROR not a map */, "foo")
+ delete(m /* ERROR "not a map" */, "foo")
}
func _[T M1](m T) {
func _[T M2](m T) {
delete(m, "foo")
- delete(m, 0 /* ERROR cannot use .* as string */)
+ delete(m, 0 /* ERROR "cannot use .* as string" */)
}
func _[T M3](m T) {
- delete(m /* ERROR must have identical key types */, "foo")
+ delete(m /* ERROR "must have identical key types" */, "foo")
}
func _[T M4[rune, V], V any](m T) {
}
func _[T M4[K, V], K comparable, V any](m T) {
- delete(m /* ERROR must have identical key types */, "foo")
+ delete(m /* ERROR "must have identical key types" */, "foo")
}
// make
_ = make([]int, 10)
_ = make(S0, 10)
_ = make(S1, 10)
- _ = make() /* ERROR not enough arguments */
- _ = make /* ERROR expects 2 or 3 arguments */ (S1)
+ _ = make() /* ERROR "not enough arguments" */
+ _ = make /* ERROR "expects 2 or 3 arguments" */ (S1)
_ = make(S1, 10, 20)
- _ = make /* ERROR expects 2 or 3 arguments */ (S1, 10, 20, 30)
- _ = make(S2 /* ERROR cannot make S2: no core type */ , 10)
+ _ = make /* ERROR "expects 2 or 3 arguments" */ (S1, 10, 20, 30)
+ _ = make(S2 /* ERROR "cannot make S2: no core type" */ , 10)
type M0 map[string]int
_ = make(map[string]int)
_ = make(M0)
_ = make(M1)
_ = make(M1, 10)
- _ = make/* ERROR expects 1 or 2 arguments */(M1, 10, 20)
- _ = make(M2 /* ERROR cannot make M2: no core type */ )
+ _ = make/* ERROR "expects 1 or 2 arguments" */(M1, 10, 20)
+ _ = make(M2 /* ERROR "cannot make M2: no core type" */ )
type C0 chan int
_ = make(chan int)
_ = make(C0)
_ = make(C1)
_ = make(C1, 10)
- _ = make/* ERROR expects 1 or 2 arguments */(C1, 10, 20)
- _ = make(C2 /* ERROR cannot make C2: no core type */ )
+ _ = make/* ERROR "expects 1 or 2 arguments" */(C1, 10, 20)
+ _ = make(C2 /* ERROR "cannot make C2: no core type" */ )
_ = make(C3)
}
const bb = unsafe.Alignof(b)
assert(bb == 8)
- const _ = unsafe /* ERROR not constant */ .Alignof(a)
- const _ = unsafe /* ERROR not constant */ .Alignof(s)
+ const _ = unsafe /* ERROR "not constant" */ .Alignof(a)
+ const _ = unsafe /* ERROR "not constant" */ .Alignof(s)
const pp = unsafe.Alignof(p)
assert(pp == 8)
const ll = unsafe.Alignof(l)
assert(cc == 8)
const mm = unsafe.Alignof(m)
assert(mm == 8)
- const _ = unsafe /* ERROR not constant */ .Alignof(t)
+ const _ = unsafe /* ERROR "not constant" */ .Alignof(t)
}
// unsafe.Offsetof
const bb = unsafe.Offsetof(b.f)
assert(bb == 8)
- const _ = unsafe /* ERROR not constant */ .Alignof(a)
- const _ = unsafe /* ERROR not constant */ .Alignof(s)
+ const _ = unsafe /* ERROR "not constant" */ .Alignof(a)
+ const _ = unsafe /* ERROR "not constant" */ .Alignof(s)
const pp = unsafe.Offsetof(p.f)
assert(pp == 8)
const ll = unsafe.Offsetof(l.f)
assert(cc == 8)
const mm = unsafe.Offsetof(m.f)
assert(mm == 8)
- const _ = unsafe /* ERROR not constant */ .Alignof(t)
+ const _ = unsafe /* ERROR "not constant" */ .Alignof(t)
}
// unsafe.Sizeof
const bb = unsafe.Sizeof(b)
assert(bb == 8)
- const _ = unsafe /* ERROR not constant */ .Alignof(a)
- const _ = unsafe /* ERROR not constant */ .Alignof(s)
+ const _ = unsafe /* ERROR "not constant" */ .Alignof(a)
+ const _ = unsafe /* ERROR "not constant" */ .Alignof(s)
const pp = unsafe.Sizeof(p)
assert(pp == 8)
const ll = unsafe.Sizeof(l)
assert(cc == 8)
const mm = unsafe.Sizeof(m)
assert(mm == 8)
- const _ = unsafe /* ERROR not constant */ .Alignof(t)
+ const _ = unsafe /* ERROR "not constant" */ .Alignof(t)
}
const c0 = x /* ERROR "not constant" */
// typed constants must have constant types
-const _ interface /* ERROR invalid constant type */ {} = 0
+const _ interface /* ERROR "invalid constant type" */ {} = 0
func _ () {
- const _ interface /* ERROR invalid constant type */ {} = 0
+ const _ interface /* ERROR "invalid constant type" */ {} = 0
for i := 0; i < 10; i++ {} // don't crash with non-nil iota here
}
const prec = 512 // internal maximum precision for integers
const maxInt = (1<<(prec/2) - 1) * (1<<(prec/2) + 1) // == 1<<prec - 1
-const _ = maxInt + /* ERROR constant addition overflow */ 1
-const _ = -maxInt - /* ERROR constant subtraction overflow */ 1
-const _ = maxInt ^ /* ERROR constant bitwise XOR overflow */ -1
-const _ = maxInt * /* ERROR constant multiplication overflow */ 2
-const _ = maxInt << /* ERROR constant shift overflow */ 2
-const _ = 1 << /* ERROR constant shift overflow */ prec
+const _ = maxInt + /* ERROR "constant addition overflow" */ 1
+const _ = -maxInt - /* ERROR "constant subtraction overflow" */ 1
+const _ = maxInt ^ /* ERROR "constant bitwise XOR overflow" */ -1
+const _ = maxInt * /* ERROR "constant multiplication overflow" */ 2
+const _ = maxInt << /* ERROR "constant shift overflow" */ 2
+const _ = 1 << /* ERROR "constant shift overflow" */ prec
-const _ = ^ /* ERROR constant bitwise complement overflow */ maxInt
+const _ = ^ /* ERROR "constant bitwise complement overflow" */ maxInt
}
// Test case for constants depending on function literals (see also #22992).
-const A /* ERROR initialization cycle */ = unsafe.Sizeof(func() { _ = A })
+const A /* ERROR "initialization cycle" */ = unsafe.Sizeof(func() { _ = A })
func _() {
// The function literal below must not see a.
const (
_ byte = 255 + iota
/* some gap */
- _ // ERROR overflows
+ _ // ERROR "overflows"
/* some gap */
- /* some gap */ _ /* ERROR overflows */; _ /* ERROR overflows */
+ /* some gap */ _ /* ERROR "overflows" */; _ /* ERROR "overflows" */
/* some gap */
_ = 255 + iota
- _ = byte /* ERROR overflows */ (255) + iota
- _ /* ERROR overflows */
+ _ = byte /* ERROR "overflows" */ (255) + iota
+ _ /* ERROR "overflows" */
)
// Test cases from issue.
ok = byte(iota + 253)
bad
barn
- bard // ERROR cannot convert
+ bard // ERROR "cannot convert"
)
const (
c = len([1 - iota]int{})
d
- e // ERROR invalid array length
- f // ERROR invalid array length
+ e // ERROR "invalid array length"
+ f // ERROR "invalid array length"
)
// Test that identifiers in implicit (omitted) RHS
type (
T0 int
- T1 /* ERROR invalid recursive type: T1 refers to itself */ T1
+ T1 /* ERROR "invalid recursive type: T1 refers to itself" */ T1
T2 *T2
- T3 /* ERROR invalid recursive type */ T4
+ T3 /* ERROR "invalid recursive type" */ T4
T4 T5
T5 T3
T8 T6
// arrays
- A0 /* ERROR invalid recursive type */ [10]A0
+ A0 /* ERROR "invalid recursive type" */ [10]A0
A1 [10]*A1
- A2 /* ERROR invalid recursive type */ [10]A3
+ A2 /* ERROR "invalid recursive type" */ [10]A3
A3 [10]A4
A4 A2
L0 []L0
// structs
- S0 /* ERROR invalid recursive type: S0 refers to itself */ struct{ _ S0 }
- S1 /* ERROR invalid recursive type: S1 refers to itself */ struct{ S1 }
+ S0 /* ERROR "invalid recursive type: S0 refers to itself" */ struct{ _ S0 }
+ S1 /* ERROR "invalid recursive type: S1 refers to itself" */ struct{ S1 }
S2 struct{ _ *S2 }
S3 struct{ *S3 }
- S4 /* ERROR invalid recursive type */ struct{ S5 }
+ S4 /* ERROR "invalid recursive type" */ struct{ S5 }
S5 struct{ S6 }
S6 S4
// pointers
P0 *P0
- PP *struct{ PP.f /* ERROR PP.f is not a type */ }
+ PP *struct{ PP.f /* ERROR "PP.f is not a type" */ }
// functions
F0 func(F0)
F2 func(F2) F2
// interfaces
- I0 /* ERROR invalid recursive type: I0 refers to itself */ interface{ I0 }
+ I0 /* ERROR "invalid recursive type: I0 refers to itself" */ interface{ I0 }
- I1 /* ERROR invalid recursive type */ interface{ I2 }
+ I1 /* ERROR "invalid recursive type" */ interface{ I2 }
I2 interface{ I3 }
I3 interface{ I1 }
I6 interface{ I5 }
// maps
- M0 map[M0 /* ERROR invalid map key */ ]M0
+ M0 map[M0 /* ERROR "invalid map key" */ ]M0
// channels
C0 chan C0
// test case for issue #34771
type (
- AA /* ERROR invalid recursive type */ B
+ AA /* ERROR "invalid recursive type" */ B
B C
C [10]D
D E
func _() {
type (
- t1 /* ERROR invalid recursive type: t1 refers to itself */ t1
+ t1 /* ERROR "invalid recursive type: t1 refers to itself" */ t1
t2 *t2
- t3 t4 /* ERROR undefined */
- t4 t5 /* ERROR undefined */
+ t3 t4 /* ERROR "undefined" */
+ t4 t5 /* ERROR "undefined" */
t5 t3
// arrays
- a0 /* ERROR invalid recursive type: a0 refers to itself */ [10]a0
+ a0 /* ERROR "invalid recursive type: a0 refers to itself" */ [10]a0
a1 [10]*a1
// slices
l0 []l0
// structs
- s0 /* ERROR invalid recursive type: s0 refers to itself */ struct{ _ s0 }
- s1 /* ERROR invalid recursive type: s1 refers to itself */ struct{ s1 }
+ s0 /* ERROR "invalid recursive type: s0 refers to itself" */ struct{ _ s0 }
+ s1 /* ERROR "invalid recursive type: s1 refers to itself" */ struct{ s1 }
s2 struct{ _ *s2 }
s3 struct{ *s3 }
f2 func(f2) f2
// interfaces
- i0 /* ERROR invalid recursive type: i0 refers to itself */ interface{ i0 }
+ i0 /* ERROR "invalid recursive type: i0 refers to itself" */ interface{ i0 }
// maps
- m0 map[m0 /* ERROR invalid map key */ ]m0
+ m0 map[m0 /* ERROR "invalid map key" */ ]m0
// channels
c0 chan c0
// test cases for issue 6667
-type A [10]map[A /* ERROR invalid map key */ ]bool
+type A [10]map[A /* ERROR "invalid map key" */ ]bool
type S struct {
- m map[S /* ERROR invalid map key */ ]bool
+ m map[S /* ERROR "invalid map key" */ ]bool
}
// test cases for issue 7236
type (
P1 *T9
- T9 /* ERROR invalid recursive type: T9 refers to itself */ T9
+ T9 /* ERROR "invalid recursive type: T9 refers to itself" */ T9
- T10 /* ERROR invalid recursive type: T10 refers to itself */ T10
+ T10 /* ERROR "invalid recursive type: T10 refers to itself" */ T10
P2 *T10
)
func (T11) m() {}
-type T11 /* ERROR invalid recursive type: T11 refers to itself */ struct{ T11 }
+type T11 /* ERROR "invalid recursive type: T11 refers to itself" */ struct{ T11 }
-type T12 /* ERROR invalid recursive type: T12 refers to itself */ struct{ T12 }
+type T12 /* ERROR "invalid recursive type: T12 refers to itself" */ struct{ T12 }
func (*T12) m() {}
type (
P3 *T13
- T13 /* ERROR invalid recursive type */ T13
+ T13 /* ERROR "invalid recursive type" */ T13
)
// test cases for issue 18643
// (type cycle detection when non-type expressions are involved)
type (
- T14 [len(T14 /* ERROR invalid recursive type */ {})]int
- T15 [][len(T15 /* ERROR invalid recursive type */ {})]int
- T16 map[[len(T16 /* ERROR invalid recursive type */ {1:2})]int]int
- T17 map[int][len(T17 /* ERROR invalid recursive type */ {1:2})]int
+ T14 [len(T14 /* ERROR "invalid recursive type" */ {})]int
+ T15 [][len(T15 /* ERROR "invalid recursive type" */ {})]int
+ T16 map[[len(T16 /* ERROR "invalid recursive type" */ {1:2})]int]int
+ T17 map[int][len(T17 /* ERROR "invalid recursive type" */ {1:2})]int
)
// Test case for types depending on function literals (see also #22992).
func _() {
type T0 func(T0)
- type T1 /* ERROR invalid recursive type */ = func(T1)
+ type T1 /* ERROR "invalid recursive type" */ = func(T1)
type T2 chan [unsafe.Sizeof(func(ch T2){ _ = <-ch })]byte
- type T3 /* ERROR invalid recursive type */ = chan [unsafe.Sizeof(func(ch T3){ _ = <-ch })]byte
+ type T3 /* ERROR "invalid recursive type" */ = chan [unsafe.Sizeof(func(ch T3){ _ = <-ch })]byte
}
// Test case for issue 6638.
type T interface {
- m() [T(nil).m /* ERROR undefined */ ()[0]]int
+ m() [T(nil).m /* ERROR "undefined" */ ()[0]]int
}
// Variations of this test case.
-type T1 /* ERROR invalid recursive type */ interface {
+type T1 /* ERROR "invalid recursive type" */ interface {
m() [x1.m()[0]]int
}
var x1 T1
-type T2 /* ERROR invalid recursive type */ interface {
+type T2 /* ERROR "invalid recursive type" */ interface {
m() [len(x2.m())]int
}
var x2 T2
-type T3 /* ERROR invalid recursive type */ interface {
+type T3 /* ERROR "invalid recursive type" */ interface {
m() [unsafe.Sizeof(x3.m)]int
}
var x3 T3
-type T4 /* ERROR invalid recursive type */ interface {
+type T4 /* ERROR "invalid recursive type" */ interface {
m() [unsafe.Sizeof(cast4(x4.m))]int // cast is invalid but we have a cycle, so all bets are off
}
)
type (
- U /* ERROR invalid recursive type */ interface {
+ U /* ERROR "invalid recursive type" */ interface {
V
}
// to follow-on errors due to an incorrectly computed type set.
type T8 interface {
- m() [unsafe.Sizeof(T8.m /* ERROR undefined */ )]int
+ m() [unsafe.Sizeof(T8.m /* ERROR "undefined" */ )]int
}
var _ = T8.m // no error expected here
type (
T1 interface { T2 }
- T2 /* ERROR invalid recursive type */ T2
+ T2 /* ERROR "invalid recursive type" */ T2
)
type (
T3 interface { T4 }
- T4 /* ERROR invalid recursive type */ T5
+ T4 /* ERROR "invalid recursive type" */ T5
T5 = T6
T6 = T7
T7 = T4
// test cases for varias alias cycles
-type T10 /* ERROR invalid recursive type */ = *T10 // issue #25141
-type T11 /* ERROR invalid recursive type */ = interface{ f(T11) } // issue #23139
+type T10 /* ERROR "invalid recursive type" */ = *T10 // issue #25141
+type T11 /* ERROR "invalid recursive type" */ = interface{ f(T11) } // issue #23139
// issue #18640
type (
type (
a struct{ *b }
b = c
- c struct{ *b /* ERROR invalid use of type alias */ }
+ c struct{ *b /* ERROR "invalid use of type alias" */ }
)
// issue #24939
}
M interface {
- F() P // ERROR invalid use of type alias
+ F() P // ERROR "invalid use of type alias"
}
P = interface {
)
// issue #8699
-type T12 /* ERROR invalid recursive type */ [len(a12)]int
+type T12 /* ERROR "invalid recursive type" */ [len(a12)]int
var a12 = makeArray()
func makeArray() (res T12) { return }
// issue #20770
-var r /* ERROR invalid cycle in declaration of r */ = newReader()
+var r /* ERROR "invalid cycle in declaration of r" */ = newReader()
func newReader() r
// variations of the theme of #8699 and #20770
-var arr /* ERROR cycle */ = f()
+var arr /* ERROR "cycle" */ = f()
func f() [len(arr)]int
// issue #25790
-func ff(ff /* ERROR not a type */ )
-func gg((gg /* ERROR not a type */ ))
+func ff(ff /* ERROR "not a type" */ )
+func gg((gg /* ERROR "not a type" */ ))
-type T13 /* ERROR invalid recursive type T13 */ [len(b13)]int
+type T13 /* ERROR "invalid recursive type T13" */ [len(b13)]int
var b13 T13
func g1() [unsafe.Sizeof(g1)]int
assert(unsafe.Sizeof(x2) == 8)
}
-func h() [h /* ERROR no value */ ()[0]]int { panic(0) }
+func h() [h /* ERROR "no value" */ ()[0]]int { panic(0) }
-var c14 /* ERROR cycle */ T14
+var c14 /* ERROR "cycle" */ T14
type T14 [uintptr(unsafe.Sizeof(&c14))]byte
// issue #34333
-type T15 /* ERROR invalid recursive type T15 */ struct {
+type T15 /* ERROR "invalid recursive type T15" */ struct {
f func() T16
b T16
}
// TODO(#43215) this should be detected as a cycle error
func f5([unsafe.Sizeof(f5)]int) {}
-func (S0) m1 (x S0.m1 /* ERROR S0.m1 is not a type */ ) {}
-func (S0) m2 (x *S0.m2 /* ERROR S0.m2 is not a type */ ) {}
-func (S0) m3 () (x S0.m3 /* ERROR S0.m3 is not a type */ ) { return }
-func (S0) m4 () (x *S0.m4 /* ERROR S0.m4 is not a type */ ) { return }
+func (S0) m1 (x S0.m1 /* ERROR "S0.m1 is not a type" */ ) {}
+func (S0) m2 (x *S0.m2 /* ERROR "S0.m2 is not a type" */ ) {}
+func (S0) m3 () (x S0.m3 /* ERROR "S0.m3 is not a type" */ ) { return }
+func (S0) m4 () (x *S0.m4 /* ERROR "S0.m4 is not a type" */ ) { return }
// interfaces may not have any blank methods
type BlankI interface {
v11 = xx/yy*yy - xx
v12 = true && false
v13 = nil /* ERROR "use of untyped nil" */
- v14 string = 257 // ERROR cannot use 257 .* as string value in variable declaration$
- v15 int8 = 257 // ERROR cannot use 257 .* as int8 value in variable declaration .*overflows
+ v14 string = 257 // ERROR "cannot use 257 .* as string value in variable declaration$"
+ v15 int8 = 257 // ERROR "cannot use 257 .* as int8 value in variable declaration .*overflows"
)
// Multiple assignment expressions
// alias receiver types
func (Ai /* ERROR "cannot define new methods on non-local type int" */) m1() {}
func (T0) m1() {}
-func (A0) m1 /* ERROR already declared */ () {}
+func (A0) m1 /* ERROR "already declared" */ () {}
func (A0) m2 () {}
-func (A3 /* ERROR invalid receiver */ ) m1 () {}
-func (A10 /* ERROR invalid receiver */ ) m1() {}
+func (A3 /* ERROR "invalid receiver" */ ) m1 () {}
+func (A10 /* ERROR "invalid receiver" */ ) m1() {}
// x0 has methods m1, m2 declared via receiver type names T0 and A0
var _ interface{ m1(); m2() } = x0
V3 = T
)
-func (V0) m /* ERROR already declared */ () {}
+func (V0) m /* ERROR "already declared" */ () {}
func (V1) n() {}
// alias receiver types (invalid due to cycles)
type (
- W0 /* ERROR invalid recursive type */ = W1
+ W0 /* ERROR "invalid recursive type" */ = W1
W1 = (W2)
W2 = ((W0))
)
B2 = int
)
-func (B0 /* ERROR cannot define new methods on non-local type int */ ) m() {}
-func (B1 /* ERROR cannot define new methods on non-local type int */ ) n() {}
+func (B0 /* ERROR "cannot define new methods on non-local type int" */ ) m() {}
+func (B1 /* ERROR "cannot define new methods on non-local type int" */ ) n() {}
// cycles
type (
- C2 /* ERROR invalid recursive type */ = C2
- C3 /* ERROR invalid recursive type */ = C4
+ C2 /* ERROR "invalid recursive type" */ = C2
+ C3 /* ERROR "invalid recursive type" */ = C4
C4 = C3
C5 struct {
f *C6
}
C6 = C5
- C7 /* ERROR invalid recursive type */ struct {
+ C7 /* ERROR "invalid recursive type" */ struct {
f C8
}
C8 = C7
// embedded fields
var (
s0 struct { T0 }
- s1 struct { A0 } = s0 /* ERROR cannot use */ // embedded field names are different
+ s1 struct { A0 } = s0 /* ERROR "cannot use" */ // embedded field names are different
)
// embedding and lookup of fields and methods
}
var (
- _ = eD{}.xf /* ERROR ambiguous selector eD{}.xf */
- _ = eD{}.xm /* ERROR ambiguous selector eD{}.xm */
+ _ = eD{}.xf /* ERROR "ambiguous selector eD{}.xf" */
+ _ = eD{}.xm /* ERROR "ambiguous selector eD{}.xm" */
)
var (
- _ interface{ xm() } = eD /* ERROR missing method xm */ {}
+ _ interface{ xm() } = eD /* ERROR "missing method xm" */ {}
)
\ No newline at end of file
// (matching messages are regular expressions, hence the \'s).
func f(x int, m map[string]int) {
// no values
- _ = f /* ERROR f\(0, m\) \(no value\) used as value */ (0, m)
+ _ = f /* ERROR "f\(0, m\) \(no value\) used as value" */ (0, m)
// built-ins
- _ = println // ERROR println \(built-in\) must be called
+ _ = println // ERROR "println \(built-in\) must be called"
// types
- _ = complex128 // ERROR complex128 \(type\) is not an expression
+ _ = complex128 // ERROR "complex128 \(type\) is not an expression"
// constants
const c1 = 991
const c2 float32 = 0.5
const c3 = "foo"
- 0 // ERROR 0 \(untyped int constant\) is not used
- 0.5 // ERROR 0.5 \(untyped float constant\) is not used
- "foo" // ERROR "foo" \(untyped string constant\) is not used
- c1 // ERROR c1 \(untyped int constant 991\) is not used
- c2 // ERROR c2 \(constant 0.5 of type float32\) is not used
- c1 /* ERROR c1 \+ c2 \(constant 991.5 of type float32\) is not used */ + c2
- c3 // ERROR c3 \(untyped string constant "foo"\) is not used
+ 0 // ERROR "0 \(untyped int constant\) is not used"
+ 0.5 // ERROR "0.5 \(untyped float constant\) is not used"
+ "foo" // ERROR ""foo" \(untyped string constant\) is not used"
+ c1 // ERROR "c1 \(untyped int constant 991\) is not used"
+ c2 // ERROR "c2 \(constant 0.5 of type float32\) is not used"
+ c1 /* ERROR "c1 \+ c2 \(constant 991.5 of type float32\) is not used" */ + c2
+ c3 // ERROR "c3 \(untyped string constant "foo"\) is not used"
// variables
- x // ERROR x \(variable of type int\) is not used
+ x // ERROR "x \(variable of type int\) is not used"
// values
- nil // ERROR nil is not used
- ( /* ERROR \(\*int\)\(nil\) \(value of type \*int\) is not used */ *int)(nil)
- x /* ERROR x != x \(untyped bool value\) is not used */ != x
- x /* ERROR x \+ x \(value of type int\) is not used */ + x
+ nil // ERROR "nil is not used"
+ ( /* ERROR "\(\*int\)\(nil\) \(value of type \*int\) is not used" */ *int)(nil)
+ x /* ERROR "x != x \(untyped bool value\) is not used" */ != x
+ x /* ERROR "x \+ x \(value of type int\) is not used" */ + x
// value, ok's
const s = "foo"
- m /* ERROR m\[s\] \(map index expression of type int\) is not used */ [s]
+ m /* ERROR "m\[s\] \(map index expression of type int\) is not used" */ [s]
}
// Valid ERROR comments can have a variety of forms.
func _() {
0 /* ERROR "0 .* is not used" */
- 0 /* ERROR 0 .* is not used */
+ 0 /* ERROR "0 .* is not used" */
+ 0 // ERROR "0 .* is not used"
0 // ERROR "0 .* is not used"
- 0 // ERROR 0 .* is not used
}
// Don't report spurious errors as a consequence of earlier errors.
// Add more tests as needed.
func _() {
- if err := foo /* ERROR undefined */ (); err != nil /* no error here */ {}
+ if err := foo /* ERROR "undefined" */ (); err != nil /* "no error here" */ {}
}
// Use unqualified names for package-local objects.
type T struct{}
-var _ int = T /* ERROR value of type T */ {} // use T in error message rather then errors.T
+var _ int = T /* ERROR "value of type T" */ {} // use T in error message rather then errors.T
// Don't report errors containing "invalid type" (issue #24182).
-func _(x *missing /* ERROR undefined: missing */ ) {
+func _(x *missing /* ERROR "undefined: missing" */ ) {
x.m() // there shouldn't be an error here referring to *invalid type
}
func g() (a, b int) { return }
func _() {
- _ = -g /* ERROR multiple-value g */ ()
- _ = <-g /* ERROR multiple-value g */ ()
+ _ = -g /* ERROR "multiple-value g" */ ()
+ _ = <-g /* ERROR "multiple-value g" */ ()
}
// ~ is accepted as unary operator only permitted in interface type elements
var (
- _ = ~ /* ERROR cannot use ~ outside of interface or type constraint */ 0
- _ = ~ /* ERROR cannot use ~ outside of interface or type constraint */ "foo"
- _ = ~ /* ERROR cannot use ~ outside of interface or type constraint */ i0
+ _ = ~ /* ERROR "cannot use ~ outside of interface or type constraint" */ 0
+ _ = ~ /* ERROR "cannot use ~ outside of interface or type constraint" */ "foo"
+ _ = ~ /* ERROR "cannot use ~ outside of interface or type constraint" */ i0
)
x = x && true
x = x && false
- z = z /* ERROR mismatched types */ || y
+ z = z /* ERROR "mismatched types" */ || y
z = z || true
z = z || false
- z = z /* ERROR mismatched types */ && y
+ z = z /* ERROR "mismatched types" */ && y
z = z && true
z = z && false
}
func _(x, y int, z myint) {
x = x + 1
x = x + 1.0
- x = x + 1.1 // ERROR truncated to int
+ x = x + 1.1 // ERROR "truncated to int"
x = x + y
x = x - y
x = x * y
z = z + 1
z = z + 1.0
- z = z + 1.1 // ERROR truncated to int
- z = z /* ERROR mismatched types */ + y
- z = z /* ERROR mismatched types */ - y
- z = z /* ERROR mismatched types */ * y
- z = z /* ERROR mismatched types */ / y
- z = z /* ERROR mismatched types */ % y
+ z = z + 1.1 // ERROR "truncated to int"
+ z = z /* ERROR "mismatched types" */ + y
+ z = z /* ERROR "mismatched types" */ - y
+ z = z /* ERROR "mismatched types" */ * y
+ z = z /* ERROR "mismatched types" */ / y
+ z = z /* ERROR "mismatched types" */ % y
z = z << y
z = z >> y
}
func _(x, y uint, z myuint) {
x = x + 1
- x = x + - /* ERROR overflows uint */ 1
+ x = x + - /* ERROR "overflows uint" */ 1
x = x + 1.0
- x = x + 1.1 // ERROR truncated to uint
+ x = x + 1.1 // ERROR "truncated to uint"
x = x + y
x = x - y
x = x * y
x = x >> y
z = z + 1
- z = x + - /* ERROR overflows uint */ 1
+ z = x + - /* ERROR "overflows uint" */ 1
z = z + 1.0
- z = z + 1.1 // ERROR truncated to uint
- z = z /* ERROR mismatched types */ + y
- z = z /* ERROR mismatched types */ - y
- z = z /* ERROR mismatched types */ * y
- z = z /* ERROR mismatched types */ / y
- z = z /* ERROR mismatched types */ % y
+ z = z + 1.1 // ERROR "truncated to uint"
+ z = z /* ERROR "mismatched types" */ + y
+ z = z /* ERROR "mismatched types" */ - y
+ z = z /* ERROR "mismatched types" */ * y
+ z = z /* ERROR "mismatched types" */ / y
+ z = z /* ERROR "mismatched types" */ % y
z = z << y
z = z >> y
}
x = x - y
x = x * y
x = x / y
- x = x /* ERROR not defined */ % y
- x = x /* ERROR operand x .* must be integer */ << y
- x = x /* ERROR operand x .* must be integer */ >> y
+ x = x /* ERROR "not defined" */ % y
+ x = x /* ERROR "operand x .* must be integer" */ << y
+ x = x /* ERROR "operand x .* must be integer" */ >> y
z = z + 1
z = z + -1
z = z + 1.0
z = z + 1.1
- z = z /* ERROR mismatched types */ + y
- z = z /* ERROR mismatched types */ - y
- z = z /* ERROR mismatched types */ * y
- z = z /* ERROR mismatched types */ / y
- z = z /* ERROR mismatched types */ % y
- z = z /* ERROR operand z .* must be integer */ << y
- z = z /* ERROR operand z .* must be integer */ >> y
+ z = z /* ERROR "mismatched types" */ + y
+ z = z /* ERROR "mismatched types" */ - y
+ z = z /* ERROR "mismatched types" */ * y
+ z = z /* ERROR "mismatched types" */ / y
+ z = z /* ERROR "mismatched types" */ % y
+ z = z /* ERROR "operand z .* must be integer" */ << y
+ z = z /* ERROR "operand z .* must be integer" */ >> y
}
type mystring string
func _(x, y string, z mystring) {
x = x + "foo"
- x = x /* ERROR not defined */ - "foo"
- x = x /* ERROR mismatched types string and untyped int */ + 1
+ x = x /* ERROR "not defined" */ - "foo"
+ x = x /* ERROR "mismatched types string and untyped int" */ + 1
x = x + y
- x = x /* ERROR not defined */ - y
- x = x /* ERROR mismatched types string and untyped int */* 10
+ x = x /* ERROR "not defined" */ - y
+ x = x /* ERROR "mismatched types string and untyped int" */* 10
}
func f() (a, b int) { return }
func _(x int) {
- _ = f /* ERROR multiple-value f */ () + 1
- _ = x + f /* ERROR multiple-value f */ ()
- _ = f /* ERROR multiple-value f */ () + f
- _ = f /* ERROR multiple-value f */ () + f /* ERROR multiple-value f */ ()
+ _ = f /* ERROR "multiple-value f" */ () + 1
+ _ = x + f /* ERROR "multiple-value f" */ ()
+ _ = f /* ERROR "multiple-value f" */ () + f
+ _ = f /* ERROR "multiple-value f" */ () + f /* ERROR "multiple-value f" */ ()
}
func _bool() {
const t = true == true
const f = true == false
- _ = t /* ERROR operator .* not defined */ < f
- _ = 0 == t /* ERROR mismatched types untyped int and untyped bool */
+ _ = t /* ERROR "operator .* not defined" */ < f
+ _ = 0 == t /* ERROR "mismatched types untyped int and untyped bool" */
var b bool
var x, y float32
b = x < y
// corner cases
var (
- v0 = nil == nil // ERROR operator == not defined on untyped nil
+ v0 = nil == nil // ERROR "operator == not defined on untyped nil"
)
func arrays() {
var a, b [10]int
_ = a == b
_ = a != b
- _ = a /* ERROR < not defined */ < b
- _ = a == nil /* ERROR mismatched types */
+ _ = a /* ERROR "< not defined" */ < b
+ _ = a == nil /* ERROR "mismatched types" */
type C [10]int
var c C
type D [10]int
var d D
- _ = c == d /* ERROR mismatched types */
+ _ = c == d /* ERROR "mismatched types" */
var e [10]func() int
- _ = e /* ERROR \[10\]func\(\) int cannot be compared */ == e
+ _ = e /* ERROR "\[10\]func\(\) int cannot be compared" */ == e
}
func structs() {
}
_ = s == t
_ = s != t
- _ = s /* ERROR < not defined */ < t
- _ = s == nil /* ERROR mismatched types */
+ _ = s /* ERROR "< not defined" */ < t
+ _ = s == nil /* ERROR "mismatched types" */
type S struct {
x int
var ss S
var tt T
_ = s == ss
- _ = ss == tt /* ERROR mismatched types */
+ _ = ss == tt /* ERROR "mismatched types" */
var u struct {
x int
a [10]map[string]int
}
- _ = u /* ERROR cannot be compared */ == u
+ _ = u /* ERROR "cannot be compared" */ == u
}
func pointers() {
// nil
- _ = nil == nil // ERROR operator == not defined on untyped nil
- _ = nil != nil // ERROR operator != not defined on untyped nil
- _ = nil /* ERROR < not defined */ < nil
- _ = nil /* ERROR <= not defined */ <= nil
- _ = nil /* ERROR > not defined */ > nil
- _ = nil /* ERROR >= not defined */ >= nil
+ _ = nil == nil // ERROR "operator == not defined on untyped nil"
+ _ = nil != nil // ERROR "operator != not defined on untyped nil"
+ _ = nil /* ERROR "< not defined" */ < nil
+ _ = nil /* ERROR "<= not defined" */ <= nil
+ _ = nil /* ERROR "> not defined" */ > nil
+ _ = nil /* ERROR ">= not defined" */ >= nil
// basics
var p, q *int
_ = nil == q
_ = nil != q
- _ = p /* ERROR < not defined */ < q
- _ = p /* ERROR <= not defined */ <= q
- _ = p /* ERROR > not defined */ > q
- _ = p /* ERROR >= not defined */ >= q
+ _ = p /* ERROR "< not defined" */ < q
+ _ = p /* ERROR "<= not defined" */ <= q
+ _ = p /* ERROR "> not defined" */ > q
+ _ = p /* ERROR ">= not defined" */ >= q
// various element types
type (
p2 P2
)
_ = ps1 == ps1
- _ = ps1 == ps2 /* ERROR mismatched types */
- _ = ps2 == ps1 /* ERROR mismatched types */
+ _ = ps1 == ps2 /* ERROR "mismatched types" */
+ _ = ps2 == ps1 /* ERROR "mismatched types" */
_ = p1 == p1
- _ = p1 == p2 /* ERROR mismatched types */
+ _ = p1 == p2 /* ERROR "mismatched types" */
_ = p1 == ps1
}
_ = c == d
_ = c != d
_ = c == nil
- _ = c /* ERROR < not defined */ < d
+ _ = c /* ERROR "< not defined" */ < d
// various element types (named types)
type (
c2 C2
)
_ = c1 == c1
- _ = c1 == c1r /* ERROR mismatched types */
- _ = c1 == c1s /* ERROR mismatched types */
- _ = c1r == c1s /* ERROR mismatched types */
+ _ = c1 == c1r /* ERROR "mismatched types" */
+ _ = c1 == c1s /* ERROR "mismatched types" */
+ _ = c1r == c1s /* ERROR "mismatched types" */
_ = c1 == c1a
_ = c1a == c1
- _ = c1 == c2 /* ERROR mismatched types */
- _ = c1a == c2 /* ERROR mismatched types */
+ _ = c1 == c2 /* ERROR "mismatched types" */
+ _ = c1a == c2 /* ERROR "mismatched types" */
// various element types (unnamed types)
var (
_ = d1 == d1
_ = d1 == d1r
_ = d1 == d1s
- _ = d1r == d1s /* ERROR mismatched types */
+ _ = d1r == d1s /* ERROR "mismatched types" */
_ = d1 == d1a
_ = d1a == d1
- _ = d1 == d2 /* ERROR mismatched types */
- _ = d1a == d2 /* ERROR mismatched types */
+ _ = d1 == d2 /* ERROR "mismatched types" */
+ _ = d1a == d2 /* ERROR "mismatched types" */
}
// for interfaces test
_ = i == j
_ = i != j
_ = i == nil
- _ = i /* ERROR < not defined */ < j
+ _ = i /* ERROR "< not defined" */ < j
// various interfaces
var ii interface { m() int; n() }
var k interface { m() float32 }
_ = i == ii
- _ = i == k /* ERROR mismatched types */
+ _ = i == k /* ERROR "mismatched types" */
// interfaces vs values
var s1 S1
var s11 S11
var s2 S2
- _ = i == 0 /* ERROR cannot convert */
- _ = i == s1 /* ERROR mismatched types */
+ _ = i == 0 /* ERROR "cannot convert" */
+ _ = i == s1 /* ERROR "mismatched types" */
_ = i == &s1
_ = i == &s11
- _ = i == s2 /* ERROR mismatched types */
- _ = i == & /* ERROR mismatched types */ s2
+ _ = i == s2 /* ERROR "mismatched types" */
+ _ = i == & /* ERROR "mismatched types" */ s2
// issue #28164
// testcase from issue
- _ = interface{}(nil) == [ /* ERROR slice can only be compared to nil */ ]int(nil)
+ _ = interface{}(nil) == [ /* ERROR "slice can only be compared to nil" */ ]int(nil)
// related cases
var e interface{}
var s []int
var x int
- _ = e == s // ERROR slice can only be compared to nil
- _ = s /* ERROR slice can only be compared to nil */ == e
- _ = e /* ERROR operator < not defined on interface */ < x
- _ = x < e // ERROR operator < not defined on interface
+ _ = e == s // ERROR "slice can only be compared to nil"
+ _ = s /* ERROR "slice can only be compared to nil" */ == e
+ _ = e /* ERROR "operator < not defined on interface" */ < x
+ _ = x < e // ERROR "operator < not defined on interface"
}
func slices() {
var s []int
_ = s == nil
_ = s != nil
- _ = s /* ERROR < not defined */ < nil
+ _ = s /* ERROR "< not defined" */ < nil
// slices are not otherwise comparable
- _ = s /* ERROR slice can only be compared to nil */ == s
- _ = s /* ERROR < not defined */ < s
+ _ = s /* ERROR "slice can only be compared to nil" */ == s
+ _ = s /* ERROR "< not defined" */ < s
}
func maps() {
var m map[string]int
_ = m == nil
_ = m != nil
- _ = m /* ERROR < not defined */ < nil
+ _ = m /* ERROR "< not defined" */ < nil
// maps are not otherwise comparable
- _ = m /* ERROR map can only be compared to nil */ == m
- _ = m /* ERROR < not defined */ < m
+ _ = m /* ERROR "map can only be compared to nil" */ == m
+ _ = m /* ERROR "< not defined" */ < m
}
func funcs() {
var f func(int) float32
_ = f == nil
_ = f != nil
- _ = f /* ERROR < not defined */ < nil
+ _ = f /* ERROR "< not defined" */ < nil
// funcs are not otherwise comparable
- _ = f /* ERROR func can only be compared to nil */ == f
- _ = f /* ERROR < not defined */ < f
+ _ = f /* ERROR "func can only be compared to nil" */ == f
+ _ = f /* ERROR "< not defined" */ < f
}
_ = time.Time{}
_ = time.Time{sec /* ERROR "unknown field" */ : 0}
_ = time.Time{
- 0 /* ERROR implicit assignment to unexported field wall in struct literal */,
- 0 /* ERROR implicit assignment */ ,
- nil /* ERROR implicit assignment */ ,
+ 0 /* ERROR "implicit assignment to unexported field wall in struct literal" */,
+ 0 /* ERROR "implicit assignment" */ ,
+ nil /* ERROR "implicit assignment" */ ,
}
}
type Array [8]byte
var s Slice
-var p = (*Array)(s /* ERROR requires go1.17 or later */ )
+var p = (*Array)(s /* ERROR "requires go1.17 or later" */ )
type Array [8]byte
var s Slice
-var p = (Array)(s /* ERROR requires go1.20 or later */)
+var p = (Array)(s /* ERROR "requires go1.20 or later" */)
package p
// type alias declarations
-type any = /* ERROR type aliases requires go1.9 or later */ interface{}
+type any = /* ERROR "type aliases requires go1.9 or later" */ interface{}
package importC
import "C"
-import _ /* ERROR cannot rename import "C" */ "C"
-import foo /* ERROR cannot rename import "C" */ "C"
-import . /* ERROR cannot rename import "C" */ "C"
+import _ /* ERROR "cannot rename import "C"" */ "C"
+import foo /* ERROR "cannot rename import "C"" */ "C"
+import . /* ERROR "cannot rename import "C"" */ "C"
// Test cases extracted from issue #22090.
import m "math"
import . "testing" // declares T in file scope
-import . /* ERROR .unsafe. imported and not used */ "unsafe"
+import . /* ERROR ".unsafe. imported and not used" */ "unsafe"
import . "fmt" // declares Println in file scope
import (
- "" /* ERROR invalid import path */
- "a!b" /* ERROR invalid import path */
- "abc\xffdef" /* ERROR invalid import path */
+ "" /* ERROR "invalid import path" */
+ "a!b" /* ERROR "invalid import path" */
+ "abc\xffdef" /* ERROR "invalid import path" */
)
// using "math" in this file doesn't affect its use in other files
package importdecl1
-import . /* ERROR .unsafe. imported and not used */ "unsafe"
+import . /* ERROR ".unsafe. imported and not used" */ "unsafe"
type B interface {
A
// initialization cycles (we don't know the types)
const (
- s0 /* ERROR initialization cycle: s0 refers to itself */ = s0
+ s0 /* ERROR "initialization cycle: s0 refers to itself" */ = s0
- x0 /* ERROR initialization cycle for x0 */ = y0
+ x0 /* ERROR "initialization cycle for x0" */ = y0
y0 = x0
a0 = b0
- b0 /* ERROR initialization cycle for b0 */ = c0
+ b0 /* ERROR "initialization cycle for b0" */ = c0
c0 = d0
d0 = b0
)
var (
- s1 /* ERROR initialization cycle: s1 refers to itself */ = s1
+ s1 /* ERROR "initialization cycle: s1 refers to itself" */ = s1
- x1 /* ERROR initialization cycle for x1 */ = y1
+ x1 /* ERROR "initialization cycle for x1" */ = y1
y1 = x1
a1 = b1
- b1 /* ERROR initialization cycle for b1 */ = c1
+ b1 /* ERROR "initialization cycle for b1" */ = c1
c1 = d1
d1 = b1
)
// initialization cycles (we know the types)
const (
- s2 /* ERROR initialization cycle: s2 refers to itself */ int = s2
+ s2 /* ERROR "initialization cycle: s2 refers to itself" */ int = s2
- x2 /* ERROR initialization cycle for x2 */ int = y2
+ x2 /* ERROR "initialization cycle for x2" */ int = y2
y2 = x2
a2 = b2
- b2 /* ERROR initialization cycle for b2 */ int = c2
+ b2 /* ERROR "initialization cycle for b2" */ int = c2
c2 = d2
d2 = b2
)
var (
- s3 /* ERROR initialization cycle: s3 refers to itself */ int = s3
+ s3 /* ERROR "initialization cycle: s3 refers to itself" */ int = s3
- x3 /* ERROR initialization cycle for x3 */ int = y3
+ x3 /* ERROR "initialization cycle for x3" */ int = y3
y3 = x3
a3 = b3
- b3 /* ERROR initialization cycle for b3 */ int = c3
+ b3 /* ERROR "initialization cycle for b3" */ int = c3
c3 = d3
d3 = b3
)
type S1 struct {
f int
}
-const cx3 S1 /* ERROR invalid constant type */ = S1{cx3.f}
-var vx3 /* ERROR initialization cycle: vx3 refers to itself */ S1 = S1{vx3.f}
+const cx3 S1 /* ERROR "invalid constant type" */ = S1{cx3.f}
+var vx3 /* ERROR "initialization cycle: vx3 refers to itself" */ S1 = S1{vx3.f}
// cycles via functions
var x4 = x5
-var x5 /* ERROR initialization cycle for x5 */ = f1()
+var x5 /* ERROR "initialization cycle for x5" */ = f1()
func f1() int { return x5*10 }
-var x6, x7 /* ERROR initialization cycle */ = f2()
+var x6, x7 /* ERROR "initialization cycle" */ = f2()
var x8 = x7
func f2() (int, int) { return f3() + f3(), 0 }
func f3() int { return x8 }
// cycles via function literals
-var x9 /* ERROR initialization cycle: x9 refers to itself */ = func() int { return x9 }()
+var x9 /* ERROR "initialization cycle: x9 refers to itself" */ = func() int { return x9 }()
-var x10 /* ERROR initialization cycle for x10 */ = f4()
+var x10 /* ERROR "initialization cycle for x10" */ = f4()
func f4() int {
_ = func() {
func (T1) m() bool { _ = x11; return false }
-var x11 /* ERROR initialization cycle for x11 */ = T1.m(T1{})
+var x11 /* ERROR "initialization cycle for x11" */ = T1.m(T1{})
// cycles via method values
func (T2) m() bool { _ = x12; return false }
var t1 T2
-var x12 /* ERROR initialization cycle for x12 */ = t1.m
+var x12 /* ERROR "initialization cycle for x12" */ = t1.m
var x0 = T0{}
-var y0 /* ERROR initialization cycle */ = x0.m()
+var y0 /* ERROR "initialization cycle" */ = x0.m()
type T1 struct{}
// issue 6703 (modified)
-var x2 /* ERROR initialization cycle */ = T2.m
+var x2 /* ERROR "initialization cycle" */ = T2.m
var y2 = x2
return 0
}
-var x3 /* ERROR initialization cycle */ = T3.m(T3{}) // <<<< added (T3{})
+var x3 /* ERROR "initialization cycle" */ = T3.m(T3{}) // <<<< added (T3{})
var y3 = x3
return 0
}
-var x4 /* ERROR initialization cycle */ = T4{}.m // <<<< added {}
+var x4 /* ERROR "initialization cycle" */ = T4{}.m // <<<< added {}
var y4 = x4
return 0
}
-var x5 /* ERROR initialization cycle */ = T5{}.m() // <<<< added ()
+var x5 /* ERROR "initialization cycle" */ = T5{}.m() // <<<< added ()
var y5 = x5
// simplified test case
var x6 = f6
-var y6 /* ERROR initialization cycle */ = f6
+var y6 /* ERROR "initialization cycle" */ = f6
func f6() { _ = y6 }
// full test case
var foo = matcher(matchList)
-var matchAny /* ERROR initialization cycle */ = matcher(matchList)
+var matchAny /* ERROR "initialization cycle" */ = matcher(matchList)
func matchAnyFn(s *S) (err E) { return matchAny(s) }
\ No newline at end of file
// cycles through functions
func f1() int { _ = x1; return 0 }
-var x1 /* ERROR initialization cycle */ = f1
+var x1 /* ERROR "initialization cycle" */ = f1
func f2() int { _ = x2; return 0 }
-var x2 /* ERROR initialization cycle */ = f2()
+var x2 /* ERROR "initialization cycle" */ = f2()
// cycles through method expressions
type T3 int
func (T3) m() int { _ = x3; return 0 }
-var x3 /* ERROR initialization cycle */ = T3.m
+var x3 /* ERROR "initialization cycle" */ = T3.m
type T4 int
func (T4) m() int { _ = x4; return 0 }
-var x4 /* ERROR initialization cycle */ = T4.m(0)
+var x4 /* ERROR "initialization cycle" */ = T4.m(0)
type T3p int
func (*T3p) m() int { _ = x3p; return 0 }
-var x3p /* ERROR initialization cycle */ = (*T3p).m
+var x3p /* ERROR "initialization cycle" */ = (*T3p).m
type T4p int
func (*T4p) m() int { _ = x4p; return 0 }
-var x4p /* ERROR initialization cycle */ = (*T4p).m(nil)
+var x4p /* ERROR "initialization cycle" */ = (*T4p).m(nil)
// cycles through method expressions of embedded methods
type T5 struct { E5 }
type E5 int
func (E5) m() int { _ = x5; return 0 }
-var x5 /* ERROR initialization cycle */ = T5.m
+var x5 /* ERROR "initialization cycle" */ = T5.m
type T6 struct { E6 }
type E6 int
func (E6) m() int { _ = x6; return 0 }
-var x6 /* ERROR initialization cycle */ = T6.m(T6{0})
+var x6 /* ERROR "initialization cycle" */ = T6.m(T6{0})
type T5p struct { E5p }
type E5p int
func (*E5p) m() int { _ = x5p; return 0 }
-var x5p /* ERROR initialization cycle */ = (*T5p).m
+var x5p /* ERROR "initialization cycle" */ = (*T5p).m
type T6p struct { E6p }
type E6p int
func (*E6p) m() int { _ = x6p; return 0 }
-var x6p /* ERROR initialization cycle */ = (*T6p).m(nil)
+var x6p /* ERROR "initialization cycle" */ = (*T6p).m(nil)
// cycles through method values
type T7 int
func (T7) m() int { _ = x7; return 0 }
-var x7 /* ERROR initialization cycle */ = T7(0).m
+var x7 /* ERROR "initialization cycle" */ = T7(0).m
type T8 int
func (T8) m() int { _ = x8; return 0 }
-var x8 /* ERROR initialization cycle */ = T8(0).m()
+var x8 /* ERROR "initialization cycle" */ = T8(0).m()
type T7p int
func (*T7p) m() int { _ = x7p; return 0 }
-var x7p /* ERROR initialization cycle */ = new(T7p).m
+var x7p /* ERROR "initialization cycle" */ = new(T7p).m
type T8p int
func (*T8p) m() int { _ = x8p; return 0 }
-var x8p /* ERROR initialization cycle */ = new(T8p).m()
+var x8p /* ERROR "initialization cycle" */ = new(T8p).m()
type T7v int
func (T7v) m() int { _ = x7v; return 0 }
var x7var T7v
-var x7v /* ERROR initialization cycle */ = x7var.m
+var x7v /* ERROR "initialization cycle" */ = x7var.m
type T8v int
func (T8v) m() int { _ = x8v; return 0 }
var x8var T8v
-var x8v /* ERROR initialization cycle */ = x8var.m()
+var x8v /* ERROR "initialization cycle" */ = x8var.m()
type T7pv int
func (*T7pv) m() int { _ = x7pv; return 0 }
var x7pvar *T7pv
-var x7pv /* ERROR initialization cycle */ = x7pvar.m
+var x7pv /* ERROR "initialization cycle" */ = x7pvar.m
type T8pv int
func (*T8pv) m() int { _ = x8pv; return 0 }
var x8pvar *T8pv
-var x8pv /* ERROR initialization cycle */ = x8pvar.m()
+var x8pv /* ERROR "initialization cycle" */ = x8pvar.m()
// cycles through method values of embedded methods
type T9 struct { E9 }
type E9 int
func (E9) m() int { _ = x9; return 0 }
-var x9 /* ERROR initialization cycle */ = T9{0}.m
+var x9 /* ERROR "initialization cycle" */ = T9{0}.m
type T10 struct { E10 }
type E10 int
func (E10) m() int { _ = x10; return 0 }
-var x10 /* ERROR initialization cycle */ = T10{0}.m()
+var x10 /* ERROR "initialization cycle" */ = T10{0}.m()
type T9p struct { E9p }
type E9p int
func (*E9p) m() int { _ = x9p; return 0 }
-var x9p /* ERROR initialization cycle */ = new(T9p).m
+var x9p /* ERROR "initialization cycle" */ = new(T9p).m
type T10p struct { E10p }
type E10p int
func (*E10p) m() int { _ = x10p; return 0 }
-var x10p /* ERROR initialization cycle */ = new(T10p).m()
+var x10p /* ERROR "initialization cycle" */ = new(T10p).m()
type T9v struct { E9v }
type E9v int
func (E9v) m() int { _ = x9v; return 0 }
var x9var T9v
-var x9v /* ERROR initialization cycle */ = x9var.m
+var x9v /* ERROR "initialization cycle" */ = x9var.m
type T10v struct { E10v }
type E10v int
func (E10v) m() int { _ = x10v; return 0 }
var x10var T10v
-var x10v /* ERROR initialization cycle */ = x10var.m()
+var x10v /* ERROR "initialization cycle" */ = x10var.m()
type T9pv struct { E9pv }
type E9pv int
func (*E9pv) m() int { _ = x9pv; return 0 }
var x9pvar *T9pv
-var x9pv /* ERROR initialization cycle */ = x9pvar.m
+var x9pv /* ERROR "initialization cycle" */ = x9pvar.m
type T10pv struct { E10pv }
type E10pv int
func (*E10pv) m() int { _ = x10pv; return 0 }
var x10pvar *T10pv
-var x10pv /* ERROR initialization cycle */ = x10pvar.m()
+var x10pv /* ERROR "initialization cycle" */ = x10pvar.m()
func issue8066() {
const (
_ = float32(340282356779733661637539395458142568447)
- _ = float32(340282356779733661637539395458142568448 /* ERROR cannot convert */ )
+ _ = float32(340282356779733661637539395458142568448 /* ERROR "cannot convert" */ )
)
}
// Check that a missing identifier doesn't lead to a spurious error cascade.
func issue8799a() {
- x, ok := missing /* ERROR undefined */ ()
+ x, ok := missing /* ERROR "undefined" */ ()
_ = !ok
_ = x
}
func issue8799b(x int, ok bool) {
- x, ok = missing /* ERROR undefined */ ()
+ x, ok = missing /* ERROR "undefined" */ ()
_ = !ok
_ = x
}
func issue9182() {
- type Point C /* ERROR undefined */ .Point
+ type Point C /* ERROR "undefined" */ .Point
// no error for composite literal based on unknown type
_ = Point{x: 1, y: 2}
}
_ = append(f0())
_ = append(f0(), f0()...)
_ = append(f1())
- _ = append(f2 /* ERROR cannot use .* in argument */ ())
- _ = append(f2()... /* ERROR cannot use ... */ )
- _ = append(f0(), f1 /* ERROR multiple-value f1 */ ())
- _ = append(f0(), f2 /* ERROR multiple-value f2 */ ())
- _ = append(f0(), f1 /* ERROR multiple-value f1 */ ()...)
- _ = append(f0(), f2 /* ERROR multiple-value f2 */ ()...)
+ _ = append(f2 /* ERROR "cannot use .* in argument" */ ())
+ _ = append(f2()... /* ERROR "cannot use ..." */ )
+ _ = append(f0(), f1 /* ERROR "multiple-value f1" */ ())
+ _ = append(f0(), f2 /* ERROR "multiple-value f2" */ ())
+ _ = append(f0(), f1 /* ERROR "multiple-value f1" */ ()...)
+ _ = append(f0(), f2 /* ERROR "multiple-value f2" */ ()...)
// variadic user-defined function
append_(f0())
append_(f0(), f0()...)
append_(f1())
- append_(f2 /* ERROR cannot use .* in argument */ ())
- append_(f2()... /* ERROR cannot use ... */ )
- append_(f0(), f1 /* ERROR multiple-value f1 */ ())
- append_(f0(), f2 /* ERROR multiple-value f2 */ ())
- append_(f0(), f1 /* ERROR multiple-value f1 */ ()...)
- append_(f0(), f2 /* ERROR multiple-value f2 */ ()...)
+ append_(f2 /* ERROR "cannot use .* in argument" */ ())
+ append_(f2()... /* ERROR "cannot use ..." */ )
+ append_(f0(), f1 /* ERROR "multiple-value f1" */ ())
+ append_(f0(), f2 /* ERROR "multiple-value f2" */ ())
+ append_(f0(), f1 /* ERROR "multiple-value f1" */ ()...)
+ append_(f0(), f2 /* ERROR "multiple-value f2" */ ()...)
}
// Check that embedding a non-interface type in an interface results in a good error message.
func issue10979() {
type _ interface {
- int /* ERROR non-interface type int */
+ int /* ERROR "non-interface type int" */
}
type T struct{}
type _ interface {
- T /* ERROR non-interface type T */
+ T /* ERROR "non-interface type T" */
}
type _ interface {
- nosuchtype /* ERROR undefined: nosuchtype */
+ nosuchtype /* ERROR "undefined: nosuchtype" */
}
type _ interface {
- fmt.Nosuchtype /* ERROR undefined: fmt\.Nosuchtype */
+ fmt.Nosuchtype /* ERROR "undefined: fmt\.Nosuchtype" */
}
type _ interface {
- nosuchpkg /* ERROR undefined: nosuchpkg */ .Nosuchtype
+ nosuchpkg /* ERROR "undefined: nosuchpkg" */ .Nosuchtype
}
type I interface {
- I.m /* ERROR I.m is not a type */
+ I.m /* ERROR "I.m is not a type" */
m()
}
}
// issue11347
// These should not crash.
-var a1, b1 /* ERROR cycle */ , c1 /* ERROR cycle */ b1 = 0 > 0<<""[""[c1]]>c1
-var a2, b2 /* ERROR cycle */ = 0 /* ERROR assignment mismatch */ /* ERROR assignment mismatch */ > 0<<""[b2]
-var a3, b3 /* ERROR cycle */ = int /* ERROR assignment mismatch */ /* ERROR assignment mismatch */ (1<<""[b3])
+var a1, b1 /* ERROR "cycle" */ , c1 /* ERROR "cycle" */ b1 = 0 > 0<<""[""[c1]]>c1
+var a2, b2 /* ERROR "cycle" */ = 0 /* ERROR "assignment mismatch" */ /* ERROR "assignment mismatch" */ > 0<<""[b2]
+var a3, b3 /* ERROR "cycle" */ = int /* ERROR "assignment mismatch" */ /* ERROR "assignment mismatch" */ (1<<""[b3])
// issue10260
// Check that error messages explain reason for interface assignment failures.
)
var x I1
- x = T1 /* ERROR cannot use T1{} .* as I1 value in assignment: T1 does not implement I1 \(method foo has pointer receiver\) */ {}
- _ = x /* ERROR impossible type assertion: x\.\(T1\)\n\tT1 does not implement I1 \(method foo has pointer receiver\) */ .(T1)
+ x = T1 /* ERROR "cannot use T1{} .* as I1 value in assignment: T1 does not implement I1 \(method foo has pointer receiver\)" */ {}
+ _ = x /* ERROR "impossible type assertion: x\.\(T1\)\n\tT1 does not implement I1 \(method foo has pointer receiver\)" */ .(T1)
- T1{}.foo /* ERROR cannot call pointer method foo on T1 */ ()
+ T1{}.foo /* ERROR "cannot call pointer method foo on T1" */ ()
x.Foo /* ERROR "x.Foo undefined \(type I1 has no field or method Foo, but does have foo\)" */ ()
- _ = i2 /* ERROR impossible type assertion: i2\.\(\*T1\)\n\t\*T1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\) */ .(*T1)
+ _ = i2 /* ERROR "impossible type assertion: i2\.\(\*T1\)\n\t\*T1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\)" */ .(*T1)
- i1 = i0 /* ERROR cannot use i0 .* as I1 value in assignment: I0 does not implement I1 \(missing method foo\) */
- i1 = t0 /* ERROR .* t0 .* as I1 .*: \*T0 does not implement I1 \(missing method foo\) */
- i1 = i2 /* ERROR .* i2 .* as I1 .*: I2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\) */
- i1 = t2 /* ERROR .* t2 .* as I1 .*: \*T2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\) */
- i2 = i1 /* ERROR .* i1 .* as I2 .*: I1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\) */
- i2 = t1 /* ERROR .* t1 .* as I2 .*: \*T1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\) */
+ i1 = i0 /* ERROR "cannot use i0 .* as I1 value in assignment: I0 does not implement I1 \(missing method foo\)" */
+ i1 = t0 /* ERROR ".* t0 .* as I1 .*: \*T0 does not implement I1 \(missing method foo\)" */
+ i1 = i2 /* ERROR ".* i2 .* as I1 .*: I2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\)" */
+ i1 = t2 /* ERROR ".* t2 .* as I1 .*: \*T2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\)" */
+ i2 = i1 /* ERROR ".* i1 .* as I2 .*: I1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\)" */
+ i2 = t1 /* ERROR ".* t1 .* as I2 .*: \*T1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\)" */
- _ = func() I1 { return i0 /* ERROR cannot use i0 .* as I1 value in return statement: I0 does not implement I1 \(missing method foo\) */ }
- _ = func() I1 { return t0 /* ERROR .* t0 .* as I1 .*: \*T0 does not implement I1 \(missing method foo\) */ }
- _ = func() I1 { return i2 /* ERROR .* i2 .* as I1 .*: I2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\) */ }
- _ = func() I1 { return t2 /* ERROR .* t2 .* as I1 .*: \*T2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\) */ }
- _ = func() I2 { return i1 /* ERROR .* i1 .* as I2 .*: I1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\) */ }
- _ = func() I2 { return t1 /* ERROR .* t1 .* as I2 .*: \*T1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\) */ }
+ _ = func() I1 { return i0 /* ERROR "cannot use i0 .* as I1 value in return statement: I0 does not implement I1 \(missing method foo\)" */ }
+ _ = func() I1 { return t0 /* ERROR ".* t0 .* as I1 .*: \*T0 does not implement I1 \(missing method foo\)" */ }
+ _ = func() I1 { return i2 /* ERROR ".* i2 .* as I1 .*: I2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\)" */ }
+ _ = func() I1 { return t2 /* ERROR ".* t2 .* as I1 .*: \*T2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\)" */ }
+ _ = func() I2 { return i1 /* ERROR ".* i1 .* as I2 .*: I1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\)" */ }
+ _ = func() I2 { return t1 /* ERROR ".* t1 .* as I2 .*: \*T1 does not implement I2 \(wrong type for method foo\)\n\t\thave foo\(\)\n\t\twant foo\(int\)" */ }
// a few more - less exhaustive now
f := func(I1, I2){}
- f(i0 /* ERROR missing method foo */ , i1 /* ERROR wrong type for method foo */ )
+ f(i0 /* ERROR "missing method foo" */ , i1 /* ERROR "wrong type for method foo" */ )
- _ = [...]I1{i0 /* ERROR cannot use i0 .* as I1 value in array or slice literal: I0 does not implement I1 \(missing method foo\) */ }
- _ = [...]I1{i2 /* ERROR cannot use i2 .* as I1 value in array or slice literal: I2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\) */ }
- _ = []I1{i0 /* ERROR missing method foo */ }
- _ = []I1{i2 /* ERROR wrong type for method foo */ }
- _ = map[int]I1{0: i0 /* ERROR missing method foo */ }
- _ = map[int]I1{0: i2 /* ERROR wrong type for method foo */ }
+ _ = [...]I1{i0 /* ERROR "cannot use i0 .* as I1 value in array or slice literal: I0 does not implement I1 \(missing method foo\)" */ }
+ _ = [...]I1{i2 /* ERROR "cannot use i2 .* as I1 value in array or slice literal: I2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(int\)\n\t\twant foo\(\)" */ }
+ _ = []I1{i0 /* ERROR "missing method foo" */ }
+ _ = []I1{i2 /* ERROR "wrong type for method foo" */ }
+ _ = map[int]I1{0: i0 /* ERROR "missing method foo" */ }
+ _ = map[int]I1{0: i2 /* ERROR "wrong type for method foo" */ }
- make(chan I1) <- i0 /* ERROR missing method foo */
- make(chan I1) <- i2 /* ERROR wrong type for method foo */
+ make(chan I1) <- i0 /* ERROR "missing method foo" */
+ make(chan I1) <- i2 /* ERROR "wrong type for method foo" */
}
// Check that constants representable as integers are in integer form
_ = x == y
// related: we should see an error since the result of f1 is ([]int, int)
- var u, v []int = f1 /* ERROR cannot use f1 */ ()
+ var u, v []int = f1 /* ERROR "cannot use f1" */ ()
_ = u
_ = v
}
// b and c must not be visible inside function literal
a := 0
a, b, c := func() (int, int, int) {
- return a, b /* ERROR undefined */ , c /* ERROR undefined */
+ return a, b /* ERROR "undefined" */ , c /* ERROR "undefined" */
}()
_, _ = b, c
}
// Test that we don't crash when the 'if' condition is missing.
func issue25438() {
- if { /* ERROR missing condition */ }
- if x := 0; /* ERROR missing condition */ { _ = x }
+ if { /* ERROR "missing condition" */ }
+ if x := 0; /* ERROR "missing condition" */ { _ = x }
if
- { /* ERROR missing condition */ }
+ { /* ERROR "missing condition" */ }
}
// Test that we can embed alias type names in interfaces.
// Test case from issue.
// cmd/compile reports a cycle as well.
-type issue25301b /* ERROR invalid recursive type */ = interface {
+type issue25301b /* ERROR "invalid recursive type" */ = interface {
m() interface{ issue25301b }
}
type issue25301c interface {
- notE // ERROR non-interface type struct\{\}
+ notE // ERROR "non-interface type struct\{\}"
}
type notE = struct{}
// Test that we don't crash when type-checking composite literals
// containing errors in the type.
-var issue27346 = [][n /* ERROR undefined */ ]int{
+var issue27346 = [][n /* ERROR "undefined" */ ]int{
0: {},
}
-var issue22467 = map[int][... /* ERROR invalid use of ... */ ]int{0: {}}
+var issue22467 = map[int][... /* ERROR "invalid use of ..." */ ]int{0: {}}
// Test that invalid use of ... in parameter lists is recognized
// (issue #28281).
func issue28281a(int, int, ...int)
func issue28281b(a, b int, c ...int)
-func issue28281c(a, b, c ... /* ERROR can only use ... with final parameter */ int)
-func issue28281d(... /* ERROR can only use ... with final parameter */ int, int)
-func issue28281e(a, b, c ... /* ERROR can only use ... with final parameter */ int, d int)
-func issue28281f(... /* ERROR can only use ... with final parameter */ int, ... /* ERROR can only use ... with final parameter */ int, int)
-func (... /* ERROR can only use ... with final parameter */ TT) f()
-func issue28281g() (... /* ERROR can only use ... with final parameter */ TT)
+func issue28281c(a, b, c ... /* ERROR "can only use ... with final parameter" */ int)
+func issue28281d(... /* ERROR "can only use ... with final parameter" */ int, int)
+func issue28281e(a, b, c ... /* ERROR "can only use ... with final parameter" */ int, d int)
+func issue28281f(... /* ERROR "can only use ... with final parameter" */ int, ... /* ERROR "can only use ... with final parameter" */ int, int)
+func (... /* ERROR "can only use ... with final parameter" */ TT) f()
+func issue28281g() (... /* ERROR "can only use ... with final parameter" */ TT)
// Issue #26234: Make various field/method lookup errors easier to read by matching cmd/compile's output
func issue26234a(f *syn.Prog) {
// The error message below should refer to the actual package name (syntax)
// not the local package name (syn).
- f.foo /* ERROR f\.foo undefined \(type \*syntax\.Prog has no field or method foo\) */
+ f.foo /* ERROR "f\.foo undefined \(type \*syntax\.Prog has no field or method foo\)" */
}
type T struct {
type E2 struct{ f int }
func issue26234b(x T) {
- _ = x.f /* ERROR ambiguous selector x.f */
+ _ = x.f /* ERROR "ambiguous selector x.f" */
}
func issue26234c() {
- T.x /* ERROR T.x undefined \(type T has no method x\) */ ()
+ T.x /* ERROR "T.x undefined \(type T has no method x\)" */ ()
}
func issue35895() {
// T is defined in this package, don't qualify its name with the package name.
- var _ T = 0 // ERROR cannot use 0 \(untyped int constant\) as T
+ var _ T = 0 // ERROR "cannot use 0 \(untyped int constant\) as T"
// There is only one package with name syntax imported, only use the (global) package name in error messages.
- var _ *syn.Prog = 0 // ERROR cannot use 0 \(untyped int constant\) as \*syntax.Prog
+ var _ *syn.Prog = 0 // ERROR "cannot use 0 \(untyped int constant\) as \*syntax.Prog"
// Because both t1 and t2 have the same global package name (template),
// qualify packages with full path name in this case.
- var _ t1.Template = t2 /* ERROR cannot use .* \(value of type .html/template.\.Template\) as .text/template.\.Template */ .Template{}
+ var _ t1.Template = t2 /* ERROR "cannot use .* \(value of type .html/template.\.Template\) as .text/template.\.Template" */ .Template{}
}
func issue42989(s uint) {
func _[X comparable, Y interface{comparable; m()}]() {
var x X
var y Y
- eql(x, y /* ERROR does not match */ ) // interfaces of different types
+ eql(x, y /* ERROR "does not match" */ ) // interfaces of different types
eql(x, x)
eql(y, y)
- eql(y, nil /* ERROR cannot use nil as Y value in argument to eql */ )
- eql[io /* ERROR does not satisfy comparable */ .Reader](nil, nil)
+ eql(y, nil /* ERROR "cannot use nil as Y value in argument to eql" */ )
+ eql[io /* ERROR "does not satisfy comparable" */ .Reader](nil, nil)
}
// If we have a receiver of pointer to type parameter type (below: *T)
// using type bound C
func _[T C[T]](x *T) {
- x.m /* ERROR x\.m undefined */ ()
+ x.m /* ERROR "x\.m undefined" */ ()
}
// using an interface literal as bound
func _[T interface{ m() }](x *T) {
- x.m /* ERROR x\.m undefined */ ()
+ x.m /* ERROR "x\.m undefined" */ ()
}
func f2[_ interface{ m1(); m2() }]() {}
func (*T) m2()
func _() {
- f2[T /* ERROR m2 has pointer receiver */ ]()
+ f2[T /* ERROR "m2 has pointer receiver" */ ]()
f2[*T]()
}
type T1[P interface{~uint}] struct{}
func _[P any]() {
- _ = T1[P /* ERROR P does not satisfy interface{~uint} */ ]{}
+ _ = T1[P /* ERROR "P does not satisfy interface{~uint}" */ ]{}
}
// This is the original (simplified) program causing the same issue.
return u.s + 1
}
-func NewT2[U any]() T2[U /* ERROR U does not satisfy Unsigned */ ] {
- return T2[U /* ERROR U does not satisfy Unsigned */ ]{}
+func NewT2[U any]() T2[U /* ERROR "U does not satisfy Unsigned" */ ] {
+ return T2[U /* ERROR "U does not satisfy Unsigned" */ ]{}
}
func _() {
}
// Infinite generic type declarations must lead to an error.
-type inf1[T any] struct{ _ inf1 /* ERROR invalid recursive type */ [T] }
-type inf2[T any] struct{ inf2 /* ERROR invalid recursive type */ [T] }
+type inf1[T any] struct{ _ inf1 /* ERROR "invalid recursive type" */ [T] }
+type inf2[T any] struct{ inf2 /* ERROR "invalid recursive type" */ [T] }
// The implementation of conversions T(x) between integers and floating-point
// numbers checks that both T and x have either integer or floating-point
// (Example by mdempsky@.)
func _[T interface { ~[10]int }](x T) {
_ = x[9] // ok
- _ = x[20 /* ERROR out of bounds */ ]
+ _ = x[20 /* ERROR "out of bounds" */ ]
}
// Pointer indirection of a type parameter.
func g[T any](T) T { panic(0) }
var _ = g[int]
-var _ = g[nil /* ERROR is not a type */ ]
+var _ = g[nil /* ERROR "is not a type" */ ]
var _ = g(0)
package main
func main()
-func main /* ERROR "no arguments and no return values" */ /* ERROR redeclared */ (int)
-func main /* ERROR "no arguments and no return values" */ /* ERROR redeclared */ () int
+func main /* ERROR "no arguments and no return values" */ /* ERROR "redeclared" */ (int)
+func main /* ERROR "no arguments and no return values" */ /* ERROR "redeclared" */ () int
package orderedmap
// TODO(gri) fix imports for tests
-import "chans" // ERROR could not import
+import "chans" // ERROR "could not import"
// Map is an ordered map.
type Map[K, V any] struct {
func _() {
var (
_ func(T0) = T0.v0
- _ = T0.p0 /* ERROR invalid method expression T0\.p0 \(needs pointer receiver \(\*T0\)\.p0\) */
+ _ = T0.p0 /* ERROR "invalid method expression T0\.p0 \(needs pointer receiver \(\*T0\)\.p0\)" */
_ func (*T0) = (*T0).v0
_ func (*T0) = (*T0).p0
_ func(T2) = T2.p2
_ func(T3) = T3.v0
- _ func(T3) = T3.p0 /* ERROR invalid method expression T3\.p0 \(needs pointer receiver \(\*T3\)\.p0\) */
+ _ func(T3) = T3.p0 /* ERROR "invalid method expression T3\.p0 \(needs pointer receiver \(\*T3\)\.p0\)" */
_ func(T3) = T3.v1
_ func(T3) = T3.p1
_ func(T3) = T3.v2
// _ = int(1.0<<s)
// _ = int(complex(1, 0)<<s)
_ = int(float32/* ERROR "must be integer" */(1.0) <<s)
- _ = int(1.1 /* ERROR must be integer */ <<s)
+ _ = int(1.1 /* ERROR "must be integer" */ <<s)
_ = int(( /* ERROR "must be integer" */ 1+1i) <<s)
_ = complex(1 /* ERROR "must be integer" */ <<s, 0)
var a = make([]int, 1<<s + 1.2 /* ERROR "truncated to int" */ )
var _ = a[1<<s - 2.3 /* ERROR "truncated to int" */ ]
var _ int = 1<<s + 3.4 /* ERROR "truncated to int" */
- var _ = string(1 /* ERROR shifted operand 1 .* must be integer */ << s)
+ var _ = string(1 /* ERROR "shifted operand 1 .* must be integer" */ << s)
var _ = string(1.0 /* ERROR "cannot convert" */ << s)
}
}
var reduced1 = Reduce[int, float64](input, 0, reducer)
-var reduced2 = Reduce(input, 1i /* ERROR overflows */, reducer) // using type inference
+var reduced2 = Reduce(input, 1i /* ERROR "overflows" */, reducer) // using type inference
var reduced3 = Reduce(input, 1, reducer) // using type inference
func filter(x int) bool {
// assignments to _
_ = nil /* ERROR "use of untyped nil" */
- _ = 1 << /* ERROR constant shift overflow */ 1000
+ _ = 1 << /* ERROR "constant shift overflow" */ 1000
(_) = 0
}
s, b = m["foo"]
_, d = m["bar"]
m["foo"] = nil
- m["foo"] = nil /* ERROR assignment mismatch: 1 variable but 2 values */ , false
+ m["foo"] = nil /* ERROR "assignment mismatch: 1 variable but 2 values" */ , false
_ = append(m["foo"])
_ = append(m["foo"], true)
var c chan int
_, b = <-c
_, d = <-c
- <- /* ERROR cannot assign */ c = 0
- <-c = 0 /* ERROR assignment mismatch: 1 variable but 2 values */ , false
+ <- /* ERROR "cannot assign" */ c = 0
+ <-c = 0 /* ERROR "assignment mismatch: 1 variable but 2 values" */ , false
var x interface{}
_, b = x.(int)
- x /* ERROR cannot assign */ .(int) = 0
- x.(int) = 0 /* ERROR assignment mismatch: 1 variable but 2 values */ , false
+ x /* ERROR "cannot assign" */ .(int) = 0
+ x.(int) = 0 /* ERROR "assignment mismatch: 1 variable but 2 values" */ , false
- assignments2 /* ERROR used as value */ () = nil
- int /* ERROR not an expression */ = 0
+ assignments2 /* ERROR "used as value" */ () = nil
+ int /* ERROR "not an expression" */ = 0
}
func issue6487() {
}
func issue6766a() {
- a, a /* ERROR a repeated on left side of := */ := 1, 2
+ a, a /* ERROR "a repeated on left side of :=" */ := 1, 2
_ = a
- a, b, b /* ERROR b repeated on left side of := */ := 1, 2, 3
+ a, b, b /* ERROR "b repeated on left side of :=" */ := 1, 2, 3
_ = b
- c, c /* ERROR c repeated on left side of := */, b := 1, 2, 3
+ c, c /* ERROR "c repeated on left side of :=" */, b := 1, 2, 3
_ = c
- a, b := /* ERROR no new variables */ 1, 2
+ a, b := /* ERROR "no new variables" */ 1, 2
}
func shortVarDecls1() {
select {
case a, b := <-ch:
_, b = a, b
- case x /* ERROR send or receive */ :
- case a /* ERROR send or receive */ := ch:
+ case x /* ERROR "send or receive" */ :
+ case a /* ERROR "send or receive" */ := ch:
}
// test for issue 9570: ch2 in second case falsely resolved to
ch2 := make(chan int)
select {
case <-ch1:
- var ch2 /* ERROR ch2 declared and not used */ chan bool
+ var ch2 /* ERROR "ch2 declared and not used" */ chan bool
case i := <-ch2:
print(i + 1)
}
func gos() {
go 1; /* ERROR "must be function call" */
go int /* ERROR "go requires function call, not conversion" */ (0)
- go ( /* ERROR expression in go must not be parenthesized */ gos())
+ go ( /* ERROR "expression in go must not be parenthesized" */ gos())
go gos()
var c chan int
go close(c)
func defers() {
defer 1; /* ERROR "must be function call" */
defer int /* ERROR "defer requires function call, not conversion" */ (0)
- defer ( /* ERROR expression in defer must not be parenthesized */ defers())
+ defer ( /* ERROR "expression in defer must not be parenthesized" */ defers())
defer defers()
var c chan int
defer close(c)
func returns0() {
return
- return 0 /* ERROR too many return values */
+ return 0 /* ERROR "too many return values" */
}
func returns1(x float64) (int, *float64) {
return 0, &x
- return /* ERROR not enough return values */
+ return /* ERROR "not enough return values" */
return "foo" /* ERROR "cannot .* in return statement" */, x /* ERROR "cannot use .* in return statement" */
- return 0, &x, 1 /* ERROR too many return values */
+ return 0, &x, 1 /* ERROR "too many return values" */
}
func returns2() (a, b int) {
return
- return 1, "foo" /* ERROR cannot use .* in return statement */
- return 1, 2, 3 /* ERROR too many return values */
+ return 1, "foo" /* ERROR "cannot use .* in return statement" */
+ return 1, 2, 3 /* ERROR "too many return values" */
{
type a int
return 1, 2
- return /* ERROR a not in scope at return */
+ return /* ERROR "a not in scope at return" */
}
}
switch uint64(x) {
case 1<<64 - 1:
- case 1 /* ERROR duplicate case */ <<64 - 1:
+ case 1 /* ERROR "duplicate case" */ <<64 - 1:
case 2, 3, 4:
- case 5, 1 /* ERROR duplicate case */ <<64 - 1:
+ case 5, 1 /* ERROR "duplicate case" */ <<64 - 1:
}
var y32 float32
switch y32 {
case 1.1:
case 11/10: // integer division!
- case 11. /* ERROR duplicate case */ /10:
+ case 11. /* ERROR "duplicate case" */ /10:
case 2, 3.0, 4.1:
- case 5.2, 1.10 /* ERROR duplicate case */ :
+ case 5.2, 1.10 /* ERROR "duplicate case" */ :
}
var y64 float64
switch y64 {
case 1.1:
case 11/10: // integer division!
- case 11. /* ERROR duplicate case */ /10:
+ case 11. /* ERROR "duplicate case" */ /10:
case 2, 3.0, 4.1:
- case 5.2, 1.10 /* ERROR duplicate case */ :
+ case 5.2, 1.10 /* ERROR "duplicate case" */ :
}
var s string
switch s {
case "foo":
- case "foo" /* ERROR duplicate case */ :
- case "f" /* ERROR duplicate case */ + "oo":
+ case "foo" /* ERROR "duplicate case" */ :
+ case "f" /* ERROR "duplicate case" */ + "oo":
case "abc", "def", "ghi":
- case "jkl", "foo" /* ERROR duplicate case */ :
+ case "jkl", "foo" /* ERROR "duplicate case" */ :
}
type T int
case (*int)(nil): // do duplicate detection
case 1:
case byte(1):
- case int /* ERROR duplicate case */ (1):
+ case int /* ERROR "duplicate case" */ (1):
case T(1):
case 1.0:
case F(1.0):
- case F /* ERROR duplicate case */ (1.0):
+ case F /* ERROR "duplicate case" */ (1.0):
case "hello":
case S("hello"):
- case S /* ERROR duplicate case */ ("hello"):
+ case S /* ERROR "duplicate case" */ ("hello"):
case 1==1, B(false):
case false, B(2==2):
}
switch x.(type) {
case int:
case float64:
- case int /* ERROR duplicate case */ :
+ case int /* ERROR "duplicate case" */ :
}
switch x.(type) {
case nil:
case int:
- case nil /* ERROR duplicate case */ , nil /* ERROR duplicate case */ :
+ case nil /* ERROR "duplicate case" */ , nil /* ERROR "duplicate case" */ :
}
type F func(int)
switch x.(type) {
case nil:
case int, func(int):
- case float32, func /* ERROR duplicate case */ (x int):
+ case float32, func /* ERROR "duplicate case" */ (x int):
case F:
}
}
var i string
_ = i
for i := 0; i < 10; i++ {}
- for i := 0; i < 10; j /* ERROR cannot declare */ := 0 {}
+ for i := 0; i < 10; j /* ERROR "cannot declare" */ := 0 {}
}
func rangeloops1() {
var a [10]int
var i I
_ = i
- for i /* ERROR cannot use .* in assignment */ = range a {}
- for i /* ERROR cannot use .* in assignment */ = range &a {}
- for i /* ERROR cannot use .* in assignment */ = range a[:] {}
+ for i /* ERROR "cannot use .* in assignment" */ = range a {}
+ for i /* ERROR "cannot use .* in assignment" */ = range &a {}
+ for i /* ERROR "cannot use .* in assignment" */ = range a[:] {}
var s string
var r R
_ = r
- for i /* ERROR cannot use .* in assignment */ = range s {}
- for i /* ERROR cannot use .* in assignment */ = range "foo" {}
- for _, r /* ERROR cannot use .* in assignment */ = range s {}
- for _, r /* ERROR cannot use .* in assignment */ = range "foo" {}
+ for i /* ERROR "cannot use .* in assignment" */ = range s {}
+ for i /* ERROR "cannot use .* in assignment" */ = range "foo" {}
+ for _, r /* ERROR "cannot use .* in assignment" */ = range s {}
+ for _, r /* ERROR "cannot use .* in assignment" */ = range "foo" {}
}
func issue6766b() {
- for _ := /* ERROR no new variables */ range "" {}
- for a, a /* ERROR redeclared */ := range "" { _ = a }
+ for _ := /* ERROR "no new variables" */ range "" {}
+ for a, a /* ERROR "redeclared" */ := range "" { _ = a }
var a int
_ = a
- for a, a /* ERROR redeclared */ := range []int{1, 2, 3} { _ = a }
+ for a, a /* ERROR "redeclared" */ := range []int{1, 2, 3} { _ = a }
}
// Test that despite errors in the range clause,
// the loop body is still type-checked (and thus
// errors reported).
func issue10148() {
- for y /* ERROR declared and not used */ := range "" {
- _ = "" /* ERROR mismatched types untyped string and untyped int */ + 1
+ for y /* ERROR "declared and not used" */ := range "" {
+ _ = "" /* ERROR "mismatched types untyped string and untyped int" */ + 1
}
- for range 1 /* ERROR cannot range over 1 */ {
- _ = "" /* ERROR mismatched types untyped string and untyped int */ + 1
+ for range 1 /* ERROR "cannot range over 1" */ {
+ _ = "" /* ERROR "mismatched types untyped string and untyped int" */ + 1
}
- for y := range 1 /* ERROR cannot range over 1 */ {
- _ = "" /* ERROR mismatched types untyped string and untyped int */ + 1
+ for y := range 1 /* ERROR "cannot range over 1" */ {
+ _ = "" /* ERROR "mismatched types untyped string and untyped int" */ + 1
}
}
// basic inference
type Tb[P ~*Q, Q any] int
func _() {
- var x Tb /* ERROR got 1 arguments */ [*int]
+ var x Tb /* ERROR "got 1 arguments" */ [*int]
var y Tb[*int, int]
- x = y /* ERROR cannot use y .* in assignment */
+ x = y /* ERROR "cannot use y .* in assignment" */
_ = x
}
// recursive inference
type Tr[A any, B *C, C *D, D *A] int
func _() {
- var x Tr /* ERROR got 1 arguments */ [string]
+ var x Tr /* ERROR "got 1 arguments" */ [string]
var y Tr[string, ***string, **string, *string]
var z Tr[int, ***int, **int, *int]
- x = y /* ERROR cannot use y .* in assignment */
- x = z // ERROR cannot use z .* as Tr
+ x = y /* ERROR "cannot use y .* in assignment" */
+ x = z // ERROR "cannot use z .* as Tr"
_ = x
}
type To3[A any, B [3]*A] int
type To4[A any, B any, C struct{a A; b B}] int
func _() {
- var _ To0 /* ERROR got 1 arguments */ [int]
- var _ To1 /* ERROR got 1 arguments */ [int]
- var _ To2 /* ERROR got 1 arguments */ [int]
- var _ To3 /* ERROR got 1 arguments */ [int]
- var _ To4 /* ERROR got 2 arguments */ [int, string]
+ var _ To0 /* ERROR "got 1 arguments" */ [int]
+ var _ To1 /* ERROR "got 1 arguments" */ [int]
+ var _ To2 /* ERROR "got 1 arguments" */ [int]
+ var _ To3 /* ERROR "got 1 arguments" */ [int]
+ var _ To4 /* ERROR "got 2 arguments" */ [int, string]
}
// failed inference
type Tf0[A, B any] int
type Tf1[A any, B ~struct{a A; c C}, C any] int
func _() {
- var _ Tf0 /* ERROR got 1 arguments but 2 type parameters */ [int]
- var _ Tf1 /* ERROR got 1 arguments but 3 type parameters */ [int]
+ var _ Tf0 /* ERROR "got 1 arguments but 2 type parameters" */ [int]
+ var _ Tf1 /* ERROR "got 1 arguments but 3 type parameters" */ [int]
}
// Parameterized type declarations
// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639).
-type T1[P any] P // ERROR cannot use a type parameter as RHS in type declaration
+type T1[P any] P // ERROR "cannot use a type parameter as RHS in type declaration"
type T2[P any] struct {
f P
// Alias type declarations cannot have type parameters.
// Issue #46477 proposses to change that.
-type A1[P any] = /* ERROR cannot be alias */ struct{}
+type A1[P any] = /* ERROR "cannot be alias" */ struct{}
// Pending clarification of #46477 we disallow aliases
// of generic types.
-type A2 = List // ERROR cannot use generic type
+type A2 = List // ERROR "cannot use generic type"
var _ A2[int]
var _ A2
// Parameterized type instantiations
var x int
-type _ x /* ERROR not a type */ [int]
+type _ x /* ERROR "not a type" */ [int]
-type _ int /* ERROR not a generic type */ [] // ERROR expected type argument list
-type _ myInt /* ERROR not a generic type */ [] // ERROR expected type argument list
+type _ int /* ERROR "not a generic type" */ [] // ERROR "expected type argument list"
+type _ myInt /* ERROR "not a generic type" */ [] // ERROR "expected type argument list"
// TODO(gri) better error messages
-type _ T1[] // ERROR expected type argument list
-type _ T1[x /* ERROR not a type */ ]
-type _ T1 /* ERROR got 2 arguments but 1 type parameters */ [int, float32]
+type _ T1[] // ERROR "expected type argument list"
+type _ T1[x /* ERROR "not a type" */ ]
+type _ T1 /* ERROR "got 2 arguments but 1 type parameters" */ [int, float32]
var _ T2[int] = T2[int]{}
// Self-recursive generic types are not permitted
-type self1[P any] self1 /* ERROR invalid recursive type */ [P]
+type self1[P any] self1 /* ERROR "invalid recursive type" */ [P]
type self2[P any] *self2[P] // this is ok
// Type sets may contain each type at most once.
type _ interface {
- ~int|~ /* ERROR overlapping terms ~int */ int
- ~int|int /* ERROR overlapping terms int */
- int|int /* ERROR overlapping terms int */
+ ~int|~ /* ERROR "overlapping terms ~int" */ int
+ ~int|int /* ERROR "overlapping terms int" */
+ int|int /* ERROR "overlapping terms int" */
}
type _ interface {
- ~struct{f int} | ~struct{g int} | ~ /* ERROR overlapping terms */ struct{f int}
+ ~struct{f int} | ~struct{g int} | ~ /* ERROR "overlapping terms" */ struct{f int}
}
// Interface term lists can contain any type, incl. *Named types.
var _ = f0[int]
var _ = f0[bool]
var _ = f0[string]
-var _ = f0[float64 /* ERROR does not satisfy I0 */ ]
+var _ = f0[float64 /* ERROR "does not satisfy I0" */ ]
type I01 interface {
E0
func f01[T I01]() {}
var _ = f01[int]
-var _ = f01[bool /* ERROR does not satisfy I0 */ ]
+var _ = f01[bool /* ERROR "does not satisfy I0" */ ]
var _ = f01[string]
-var _ = f01[float64 /* ERROR does not satisfy I0 */ ]
+var _ = f01[float64 /* ERROR "does not satisfy I0" */ ]
type I012 interface {
E0
}
func f012[T I012]() {}
-var _ = f012[int /* ERROR cannot satisfy I012.*empty type set */ ]
-var _ = f012[bool /* ERROR cannot satisfy I012.*empty type set */ ]
-var _ = f012[string /* ERROR cannot satisfy I012.*empty type set */ ]
-var _ = f012[float64 /* ERROR cannot satisfy I012.*empty type set */ ]
+var _ = f012[int /* ERROR "cannot satisfy I012.*empty type set" */ ]
+var _ = f012[bool /* ERROR "cannot satisfy I012.*empty type set" */ ]
+var _ = f012[string /* ERROR "cannot satisfy I012.*empty type set" */ ]
+var _ = f012[float64 /* ERROR "cannot satisfy I012.*empty type set" */ ]
type I12 interface {
E1
}
func f12[T I12]() {}
-var _ = f12[int /* ERROR does not satisfy I12 */ ]
-var _ = f12[bool /* ERROR does not satisfy I12 */ ]
-var _ = f12[string /* ERROR does not satisfy I12 */ ]
+var _ = f12[int /* ERROR "does not satisfy I12" */ ]
+var _ = f12[bool /* ERROR "does not satisfy I12" */ ]
+var _ = f12[string /* ERROR "does not satisfy I12" */ ]
var _ = f12[float64]
type I0_ interface {
func f0_[T I0_]() {}
var _ = f0_[int]
-var _ = f0_[bool /* ERROR does not satisfy I0_ */ ]
-var _ = f0_[string /* ERROR does not satisfy I0_ */ ]
-var _ = f0_[float64 /* ERROR does not satisfy I0_ */ ]
+var _ = f0_[bool /* ERROR "does not satisfy I0_" */ ]
+var _ = f0_[string /* ERROR "does not satisfy I0_" */ ]
+var _ = f0_[float64 /* ERROR "does not satisfy I0_" */ ]
// Using a function instance as a type is an error.
-var _ f0 // ERROR not a type
-var _ f0 /* ERROR not a type */ [int]
+var _ f0 // ERROR "not a type"
+var _ f0 /* ERROR "not a type" */ [int]
// Empty type sets can only be satisfied by empty type sets.
type none interface {
func hh[T ~int]() {}
func _[T none]() {
- _ = ff[int /* ERROR cannot satisfy none \(empty type set\) */ ]
+ _ = ff[int /* ERROR "cannot satisfy none \(empty type set\)" */ ]
_ = ff[T] // pathological but ok because T's type set is empty, too
_ = gg[int]
_ = gg[T]
func identity[T any](x T) T { return x }
func _[_ any](x int) int { panic(0) }
-func _[T any](T /* ERROR redeclared */ T)() {}
-func _[T, T /* ERROR redeclared */ any]() {}
+func _[T any](T /* ERROR "redeclared" */ T)() {}
+func _[T, T /* ERROR "redeclared" */ any]() {}
// Constraints (incl. any) may be parenthesized.
func _[_ (any)]() {}
return rlist
}
-var _ = reverse /* ERROR cannot use generic function reverse */
-var _ = reverse[int, float32 /* ERROR got 2 type arguments */ ] ([]int{1, 2, 3})
-var _ = reverse[int]([ /* ERROR cannot use */ ]float32{1, 2, 3})
+var _ = reverse /* ERROR "cannot use generic function reverse" */
+var _ = reverse[int, float32 /* ERROR "got 2 type arguments" */ ] ([]int{1, 2, 3})
+var _ = reverse[int]([ /* ERROR "cannot use" */ ]float32{1, 2, 3})
var f = reverse[chan int]
-var _ = f(0 /* ERROR cannot use 0 .* as \[\]chan int */ )
+var _ = f(0 /* ERROR "cannot use 0 .* as \[\]chan int" */ )
func swap[A, B any](a A, b B) (B, A) { return b, a }
-var _ = swap /* ERROR multiple-value */ [int, float32](1, 2)
+var _ = swap /* ERROR "multiple-value" */ [int, float32](1, 2)
var f32, i = swap[int, float32](swap[float32, int](1, 2))
var _ float32 = f32
var _ int = i
}
func _[T interface{~int | ~float32}](x, y T) bool { return x < y }
-func _[T any](x, y T) bool { return x /* ERROR type parameter T is not comparable */ < y }
-func _[T interface{~int | ~float32 | ~bool}](x, y T) bool { return x /* ERROR type parameter T is not comparable */ < y }
+func _[T any](x, y T) bool { return x /* ERROR "type parameter T is not comparable" */ < y }
+func _[T interface{~int | ~float32 | ~bool}](x, y T) bool { return x /* ERROR "type parameter T is not comparable" */ < y }
-func _[T C1[T]](x, y T) bool { return x /* ERROR type parameter T is not comparable */ < y }
+func _[T C1[T]](x, y T) bool { return x /* ERROR "type parameter T is not comparable" */ < y }
func _[T C2[T]](x, y T) bool { return x < y }
type C1[T any] interface{}
return &x
}
-var _ = new /* ERROR cannot use generic function new */
+var _ = new /* ERROR "cannot use generic function new" */
var _ *int = new[int]()
-func _[T any](map[T /* ERROR invalid map key type T \(missing comparable constraint\) */]int) {} // w/o constraint we don't know if T is comparable
+func _[T any](map[T /* ERROR "invalid map key type T \(missing comparable constraint\)" */]int) {} // w/o constraint we don't know if T is comparable
-func f1[T1 any](struct{T1 /* ERROR cannot be a .* type parameter */ }) int { panic(0) }
+func f1[T1 any](struct{T1 /* ERROR "cannot be a .* type parameter" */ }) int { panic(0) }
var _ = f1[int](struct{T1}{})
type T1 = int
-func f2[t1 any](struct{t1 /* ERROR cannot be a .* type parameter */ ; x float32}) int { panic(0) }
+func f2[t1 any](struct{t1 /* ERROR "cannot be a .* type parameter" */ ; x float32}) int { panic(0) }
var _ = f2[t1](struct{t1; x float32}{})
type t1 = int
func _[T interface{ ~int }] (x T, i int) { _ = x /* ERROR "cannot index" */ [i] }
func _[T interface{ ~string }] (x T, i int) { _ = x[i] }
func _[T interface{ ~[]int }] (x T, i int) { _ = x[i] }
-func _[T interface{ ~[10]int | ~*[20]int | ~map[int]int }] (x T, i int) { _ = x /* ERROR cannot index */ [i] } // map and non-map types
+func _[T interface{ ~[10]int | ~*[20]int | ~map[int]int }] (x T, i int) { _ = x /* ERROR "cannot index" */ [i] } // map and non-map types
func _[T interface{ ~string | ~[]byte }] (x T, i int) { _ = x[i] }
func _[T interface{ ~[]int | ~[1]rune }] (x T, i int) { _ = x /* ERROR "cannot index" */ [i] }
func _[T interface{ ~string | ~[]rune }] (x T, i int) { _ = x /* ERROR "cannot index" */ [i] }
// indexing with various combinations of map types in type sets (see issue #42616)
-func _[T interface{ ~[]E | ~map[int]E }, E any](x T, i int) { _ = x /* ERROR cannot index */ [i] } // map and non-map types
+func _[T interface{ ~[]E | ~map[int]E }, E any](x T, i int) { _ = x /* ERROR "cannot index" */ [i] } // map and non-map types
func _[T interface{ ~[]E }, E any](x T, i int) { _ = &x[i] }
func _[T interface{ ~map[int]E }, E any](x T, i int) { _, _ = x[i] } // comma-ok permitted
-func _[T interface{ ~map[int]E }, E any](x T, i int) { _ = &x /* ERROR cannot take address */ [i] }
-func _[T interface{ ~map[int]E | ~map[uint]E }, E any](x T, i int) { _ = x /* ERROR cannot index */ [i] } // different map element types
-func _[T interface{ ~[]E | ~map[string]E }, E any](x T, i int) { _ = x /* ERROR cannot index */ [i] } // map and non-map types
+func _[T interface{ ~map[int]E }, E any](x T, i int) { _ = &x /* ERROR "cannot take address" */ [i] }
+func _[T interface{ ~map[int]E | ~map[uint]E }, E any](x T, i int) { _ = x /* ERROR "cannot index" */ [i] } // different map element types
+func _[T interface{ ~[]E | ~map[string]E }, E any](x T, i int) { _ = x /* ERROR "cannot index" */ [i] } // map and non-map types
// indexing with various combinations of array and other types in type sets
-func _[T interface{ [10]int }](x T, i int) { _ = x[i]; _ = x[9]; _ = x[10 /* ERROR out of bounds */ ] }
-func _[T interface{ [10]byte | string }](x T, i int) { _ = x[i]; _ = x[9]; _ = x[10 /* ERROR out of bounds */ ] }
-func _[T interface{ [10]int | *[20]int | []int }](x T, i int) { _ = x[i]; _ = x[9]; _ = x[10 /* ERROR out of bounds */ ] }
+func _[T interface{ [10]int }](x T, i int) { _ = x[i]; _ = x[9]; _ = x[10 /* ERROR "out of bounds" */ ] }
+func _[T interface{ [10]byte | string }](x T, i int) { _ = x[i]; _ = x[9]; _ = x[10 /* ERROR "out of bounds" */ ] }
+func _[T interface{ [10]int | *[20]int | []int }](x T, i int) { _ = x[i]; _ = x[9]; _ = x[10 /* ERROR "out of bounds" */ ] }
// indexing with strings and non-variable arrays (assignment not permitted)
-func _[T string](x T) { _ = x[0]; x /* ERROR cannot assign */ [0] = 0 }
-func _[T []byte | string](x T) { x /* ERROR cannot assign */ [0] = 0 }
-func _[T [10]byte]() { f := func() (x T) { return }; f /* ERROR cannot assign */ ()[0] = 0 }
-func _[T [10]byte]() { f := func() (x *T) { return }; f /* ERROR cannot index */ ()[0] = 0 }
+func _[T string](x T) { _ = x[0]; x /* ERROR "cannot assign" */ [0] = 0 }
+func _[T []byte | string](x T) { x /* ERROR "cannot assign" */ [0] = 0 }
+func _[T [10]byte]() { f := func() (x T) { return }; f /* ERROR "cannot assign" */ ()[0] = 0 }
+func _[T [10]byte]() { f := func() (x *T) { return }; f /* ERROR "cannot index" */ ()[0] = 0 }
func _[T [10]byte]() { f := func() (x *T) { return }; (*f())[0] = 0 }
func _[T *[10]byte]() { f := func() (x T) { return }; f()[0] = 0 }
func _[T interface{ ~[]byte }] (x T, i, j, k int) { var _ T = x[i:j] }
func _[T interface{ ~[]byte }] (x T, i, j, k int) { var _ T = x[i:j:k] }
func _[T interface{ ~string }] (x T, i, j, k int) { var _ T = x[i:j] }
-func _[T interface{ ~string }] (x T, i, j, k int) { var _ T = x[i:j:k /* ERROR 3-index slice of string */ ] }
+func _[T interface{ ~string }] (x T, i, j, k int) { var _ T = x[i:j:k /* ERROR "3-index slice of string" */ ] }
type myByte1 []byte
type myByte2 []byte
func _[T interface{ []byte | myByte1 | myByte2 }] (x T, i, j, k int) { var _ T = x[i:j:k] }
-func _[T interface{ []byte | myByte1 | []int }] (x T, i, j, k int) { var _ T = x /* ERROR no core type */ [i:j:k] }
+func _[T interface{ []byte | myByte1 | []int }] (x T, i, j, k int) { var _ T = x /* ERROR "no core type" */ [i:j:k] }
func _[T interface{ []byte | myByte1 | myByte2 | string }] (x T, i, j, k int) { var _ T = x[i:j] }
-func _[T interface{ []byte | myByte1 | myByte2 | string }] (x T, i, j, k int) { var _ T = x[i:j:k /* ERROR 3-index slice of string */ ] }
-func _[T interface{ []byte | myByte1 | []int | string }] (x T, i, j, k int) { var _ T = x /* ERROR no core type */ [i:j] }
+func _[T interface{ []byte | myByte1 | myByte2 | string }] (x T, i, j, k int) { var _ T = x[i:j:k /* ERROR "3-index slice of string" */ ] }
+func _[T interface{ []byte | myByte1 | []int | string }] (x T, i, j, k int) { var _ T = x /* ERROR "no core type" */ [i:j] }
// len/cap built-ins
-func _[T any](x T) { _ = len(x /* ERROR invalid argument */ ) }
-func _[T interface{ ~int }](x T) { _ = len(x /* ERROR invalid argument */ ) }
-func _[T interface{ ~string | ~[]byte | ~int }](x T) { _ = len(x /* ERROR invalid argument */ ) }
+func _[T any](x T) { _ = len(x /* ERROR "invalid argument" */ ) }
+func _[T interface{ ~int }](x T) { _ = len(x /* ERROR "invalid argument" */ ) }
+func _[T interface{ ~string | ~[]byte | ~int }](x T) { _ = len(x /* ERROR "invalid argument" */ ) }
func _[T interface{ ~string }](x T) { _ = len(x) }
func _[T interface{ ~[10]int }](x T) { _ = len(x) }
func _[T interface{ ~[]byte }](x T) { _ = len(x) }
func _[T interface{ ~chan int }](x T) { _ = len(x) }
func _[T interface{ ~string | ~[]byte | ~chan int }](x T) { _ = len(x) }
-func _[T any](x T) { _ = cap(x /* ERROR invalid argument */ ) }
-func _[T interface{ ~int }](x T) { _ = cap(x /* ERROR invalid argument */ ) }
-func _[T interface{ ~string | ~[]byte | ~int }](x T) { _ = cap(x /* ERROR invalid argument */ ) }
-func _[T interface{ ~string }](x T) { _ = cap(x /* ERROR invalid argument */ ) }
+func _[T any](x T) { _ = cap(x /* ERROR "invalid argument" */ ) }
+func _[T interface{ ~int }](x T) { _ = cap(x /* ERROR "invalid argument" */ ) }
+func _[T interface{ ~string | ~[]byte | ~int }](x T) { _ = cap(x /* ERROR "invalid argument" */ ) }
+func _[T interface{ ~string }](x T) { _ = cap(x /* ERROR "invalid argument" */ ) }
func _[T interface{ ~[10]int }](x T) { _ = cap(x) }
func _[T interface{ ~[]byte }](x T) { _ = cap(x) }
-func _[T interface{ ~map[int]int }](x T) { _ = cap(x /* ERROR invalid argument */ ) }
+func _[T interface{ ~map[int]int }](x T) { _ = cap(x /* ERROR "invalid argument" */ ) }
func _[T interface{ ~chan int }](x T) { _ = cap(x) }
func _[T interface{ ~[]byte | ~chan int }](x T) { _ = cap(x) }
// range iteration
func _[T interface{}](x T) {
- for range x /* ERROR cannot range */ {}
+ for range x /* ERROR "cannot range" */ {}
}
type myString string
var c0 chan int
for range c0 {}
for _ = range c0 {}
- for _, _ /* ERROR permits only one iteration variable */ = range c0 {}
+ for _, _ /* ERROR "permits only one iteration variable" */ = range c0 {}
var c1 C1
for range c1 {}
for _ = range c1 {}
- for _, _ /* ERROR permits only one iteration variable */ = range c1 {}
+ for _, _ /* ERROR "permits only one iteration variable" */ = range c1 {}
var c2 C2
for range c2 {}
var c3 C3
- for range c3 /* ERROR receive from send-only channel */ {}
+ for range c3 /* ERROR "receive from send-only channel" */ {}
var s0 []int
for range s0 {}
for _, _ = range s1 {}
var s2 S2
- for range s2 /* ERROR cannot range over s2.*no core type */ {}
+ for range s2 /* ERROR "cannot range over s2.*no core type" */ {}
var a0 []int
for range a0 {}
for _, _ = range a1 {}
var a2 A2
- for range a2 /* ERROR cannot range over a2.*no core type */ {}
+ for range a2 /* ERROR "cannot range over a2.*no core type" */ {}
var p0 *[10]int
for range p0 {}
for _, _ = range p1 {}
var p2 P2
- for range p2 /* ERROR cannot range over p2.*no core type */ {}
+ for range p2 /* ERROR "cannot range over p2.*no core type" */ {}
var m0 map[string]int
for range m0 {}
for _, _ = range m1 {}
var m2 M2
- for range m2 /* ERROR cannot range over m2.*no core type */ {}
+ for range m2 /* ERROR "cannot range over m2.*no core type" */ {}
}
// type inference checks
-var _ = new /* ERROR cannot infer T */ ()
+var _ = new /* ERROR "cannot infer T" */ ()
func f4[A, B, C any](A, B) C { panic(0) }
-var _ = f4 /* ERROR cannot infer C */ (1, 2)
+var _ = f4 /* ERROR "cannot infer C" */ (1, 2)
var _ = f4[int, float32, complex128](1, 2)
func f5[A, B, C any](A, []*B, struct{f []C}) int { panic(0) }
var _ = f5[int, float32, complex128](0, nil, struct{f []complex128}{})
-var _ = f5 /* ERROR cannot infer */ (0, nil, struct{f []complex128}{})
+var _ = f5 /* ERROR "cannot infer" */ (0, nil, struct{f []complex128}{})
var _ = f5(0, []*float32{new[float32]()}, struct{f []complex128}{})
func f6[A any](A, []A) int { panic(0) }
func f6nil[A any](A) int { panic(0) }
-var _ = f6nil /* ERROR cannot infer */ (nil)
+var _ = f6nil /* ERROR "cannot infer" */ (nil)
// type inference with variadic functions
func f7[T any](...T) T { panic(0) }
-var _ int = f7 /* ERROR cannot infer T */ ()
+var _ int = f7 /* ERROR "cannot infer T" */ ()
var _ int = f7(1)
var _ int = f7(1, 2)
var _ int = f7([]int{}...)
-var _ int = f7 /* ERROR cannot use */ ([]float64{}...)
+var _ int = f7 /* ERROR "cannot use" */ ([]float64{}...)
var _ float64 = f7([]float64{}...)
var _ = f7[float64](1, 2.3)
var _ = f7(float64(1), 2.3)
-var _ = f7(1, 2.3 /* ERROR does not match */ )
-var _ = f7(1.2, 3 /* ERROR does not match */ )
+var _ = f7(1, 2.3 /* ERROR "does not match" */ )
+var _ = f7(1.2, 3 /* ERROR "does not match" */ )
func f8[A, B any](A, B, ...B) int { panic(0) }
-var _ = f8(1) /* ERROR not enough arguments */
+var _ = f8(1) /* ERROR "not enough arguments" */
var _ = f8(1, 2.3)
var _ = f8(1, 2.3, 3.4, 4.5)
-var _ = f8(1, 2.3, 3.4, 4 /* ERROR does not match */ )
+var _ = f8(1, 2.3, 3.4, 4 /* ERROR "does not match" */ )
var _ = f8[int, float64](1, 2.3, 3.4, 4)
var _ = f8[int, float64](0, 0, nil...) // test case for #18268
// init functions cannot have type parameters
func init() {}
-func init[_ /* ERROR func init must have no type parameters */ any]() {}
-func init[P /* ERROR func init must have no type parameters */ any]() {}
+func init[_ /* ERROR "func init must have no type parameters" */ any]() {}
+func init[P /* ERROR "func init must have no type parameters" */ any]() {}
type T struct {}
func (T) m1() {}
-func (T) m2[ /* ERROR method must have no type parameters */ _ any]() {}
-func (T) m3[ /* ERROR method must have no type parameters */ P any]() {}
+func (T) m2[ /* ERROR "method must have no type parameters" */ _ any]() {}
+func (T) m3[ /* ERROR "method must have no type parameters" */ P any]() {}
// type inference across parameterized types
// }
//
// // type assertions and type switches over generic types are strict
-// _ = p /* ERROR cannot have dynamic type I4 */.(I4)
+// _ = p /* ERROR "cannot have dynamic type I4" */.(I4)
// switch p.(type) {
-// case I4 /* ERROR cannot have dynamic type I4 */ :
+// case I4 /* ERROR "cannot have dynamic type I4" */ :
// }
// }
// type assertions and type switches over generic types lead to errors for now
func _[T any](x T) {
- _ = x /* ERROR cannot use type assertion */ .(int)
- switch x /* ERROR cannot use type switch */ .(type) {
+ _ = x /* ERROR "cannot use type assertion" */ .(int)
+ switch x /* ERROR "cannot use type switch" */ .(type) {
}
// work-around
}
func _[T interface{~int}](x T) {
- _ = x /* ERROR cannot use type assertion */ .(int)
- switch x /* ERROR cannot use type switch */ .(type) {
+ _ = x /* ERROR "cannot use type assertion" */ .(int)
+ switch x /* ERROR "cannot use type switch" */ .(type) {
}
// work-around
type C[P any] interface{}
func _[P C[P]] (x P) {
- x.m /* ERROR x.m undefined */ ()
+ x.m /* ERROR "x.m undefined" */ ()
}
type I interface {}
func _[P I] (x P) {
- x.m /* ERROR type P has no field or method m */ ()
+ x.m /* ERROR "type P has no field or method m" */ ()
}
func _[P interface{}] (x P) {
- x.m /* ERROR type P has no field or method m */ ()
+ x.m /* ERROR "type P has no field or method m" */ ()
}
func _[P any] (x P) {
- x.m /* ERROR type P has no field or method m */ ()
+ x.m /* ERROR "type P has no field or method m" */ ()
}
t70|t71|t72|t73|t74|t75|t76|t77|t78|t79|
t80|t81|t82|t83|t84|t85|t86|t87|t88|t89|
t90|t91|t92|t93|t94|t95|t96|t97|t98|t99|
- int // ERROR cannot handle more than 100 union terms
+ int // ERROR "cannot handle more than 100 union terms"
}
type u102 interface {
- int /* ERROR cannot handle more than 100 union terms */ |string|u100a
+ int /* ERROR "cannot handle more than 100 union terms" */ |string|u100a
}
type u200 interface {
- u100a /* ERROR cannot handle more than 100 union terms */ |u100b
+ u100a /* ERROR "cannot handle more than 100 union terms" */ |u100b
}
// Unused variables in function literals must lead to only one error (issue #22524).
func _() {
_ = func() {
- var x /* ERROR declared and not used */ int
+ var x /* ERROR "declared and not used" */ int
}
}
func _() {
var x int
- return x /* ERROR too many return values */
- return math /* ERROR too many return values */ .Sin(0)
+ return x /* ERROR "too many return values" */
+ return math /* ERROR "too many return values" */ .Sin(0)
}
func _() int {
var x, y int
- return x, y /* ERROR too many return values */
+ return x, y /* ERROR "too many return values" */
}
// Short variable declarations must declare at least one new non-blank variable.
func _() {
- _ := /* ERROR no new variables */ 0
+ _ := /* ERROR "no new variables" */ 0
_, a := 0, 1
- _, a := /* ERROR no new variables */ 0, 1
+ _, a := /* ERROR "no new variables" */ 0, 1
_, a, b := 0, 1, 2
- _, _, _ := /* ERROR no new variables */ 0, 1, 2
+ _, _, _ := /* ERROR "no new variables" */ 0, 1, 2
_ = a
_ = b
}
// Test case for variables depending on function literals (see also #22992).
-var A /* ERROR initialization cycle */ = func() int { return A }()
+var A /* ERROR "initialization cycle" */ = func() int { return A }()
func _() {
// The function literal below must not see a.
union interface{int|~string}
// Union terms must describe disjoint (non-overlapping) type sets.
- _ interface{int|int /* ERROR overlapping terms int */ }
- _ interface{int|~ /* ERROR overlapping terms ~int */ int }
- _ interface{~int|~ /* ERROR overlapping terms ~int */ int }
- _ interface{~int|MyInt /* ERROR overlapping terms p.MyInt and ~int */ }
+ _ interface{int|int /* ERROR "overlapping terms int" */ }
+ _ interface{int|~ /* ERROR "overlapping terms ~int" */ int }
+ _ interface{~int|~ /* ERROR "overlapping terms ~int" */ int }
+ _ interface{~int|MyInt /* ERROR "overlapping terms p.MyInt and ~int" */ }
_ interface{int|any}
_ interface{int|~string|union}
_ interface{int|~string|interface{int}}
_ interface{union|union} // ditto
// For now we do not permit interfaces with methods in unions.
- _ interface{~ /* ERROR invalid use of ~ */ any}
- _ interface{int|interface /* ERROR cannot use .* in union */ { m() }}
+ _ interface{~ /* ERROR "invalid use of ~" */ any}
+ _ interface{int|interface /* ERROR "cannot use .* in union" */ { m() }}
)
type (
foo int
bar any
_ interface{foo}
- _ interface{~ /* ERROR invalid use of ~ */ foo }
- _ interface{~ /* ERROR invalid use of ~ */ bar }
+ _ interface{~ /* ERROR "invalid use of ~" */ foo }
+ _ interface{~ /* ERROR "invalid use of ~" */ bar }
)
// Stand-alone type parameters are not permitted as elements or terms in unions.
type (
_[T interface{ *T } ] struct{} // ok
_[T interface{ int | *T } ] struct{} // ok
- _[T interface{ T /* ERROR term cannot be a type parameter */ } ] struct{}
- _[T interface{ ~T /* ERROR type in term ~T cannot be a type parameter */ } ] struct{}
- _[T interface{ int|T /* ERROR term cannot be a type parameter */ }] struct{}
+ _[T interface{ T /* ERROR "term cannot be a type parameter" */ } ] struct{}
+ _[T interface{ ~T /* ERROR "type in term ~T cannot be a type parameter" */ } ] struct{}
+ _[T interface{ int|T /* ERROR "term cannot be a type parameter" */ }] struct{}
)
// Multiple embedded union elements are intersected. The order in which they
func _[T interface{ ~int; myInt1|myInt2 }]() T { return T(0) }
// Here the intersections are empty - there's no type that's in the type set of T.
-func _[T interface{ myInt1|myInt2; int }]() T { return T(0 /* ERROR cannot convert */ ) }
-func _[T interface{ int; myInt1|myInt2 }]() T { return T(0 /* ERROR cannot convert */ ) }
+func _[T interface{ myInt1|myInt2; int }]() T { return T(0 /* ERROR "cannot convert" */ ) }
+func _[T interface{ int; myInt1|myInt2 }]() T { return T(0 /* ERROR "cannot convert" */ ) }
// Union elements may be interfaces as long as they don't define
// any methods or embed comparable.
Number interface{ Integer|Unsigned|Floats|Complex }
Ordered interface{ Integer|Unsigned|Floats|~string }
- _ interface{ Number | error /* ERROR cannot use error in union */ }
- _ interface{ Ordered | comparable /* ERROR cannot use comparable in union */ }
+ _ interface{ Number | error /* ERROR "cannot use error in union" */ }
+ _ interface{ Ordered | comparable /* ERROR "cannot use comparable in union" */ }
)
// for variadic functions.
func variadic[A, B any](A, B, ...B) int { panic(0) }
-// var _ = variadic(1) // ERROR not enough arguments
+// var _ = variadic(1) // ERROR "not enough arguments"
var _ = variadic(1, 2.3)
var _ = variadic(1, 2.3, 3.4, 4.5)
var _ = variadic[int, float64](1, 2.3, 3.4, 4)
var send chan<-int
fboth(both)
- fboth(recv /* ERROR cannot use */ )
- fboth(send /* ERROR cannot use */ )
+ fboth(recv /* ERROR "cannot use" */ )
+ fboth(send /* ERROR "cannot use" */ )
frecv(both)
frecv(recv)
- frecv(send /* ERROR cannot use */ )
+ frecv(send /* ERROR "cannot use" */ )
fsend(both)
- fsend(recv /* ERROR cannot use */)
+ fsend(recv /* ERROR "cannot use" */)
fsend(send)
}
var send func(chan<- int)
ffboth(both)
- ffboth(recv /* ERROR cannot use */ )
- ffboth(send /* ERROR cannot use */ )
+ ffboth(recv /* ERROR "cannot use" */ )
+ ffboth(send /* ERROR "cannot use" */ )
- ffrecv(both /* ERROR cannot use */ )
+ ffrecv(both /* ERROR "cannot use" */ )
ffrecv(recv)
- ffrecv(send /* ERROR cannot use */ )
+ ffrecv(send /* ERROR "cannot use" */ )
- ffsend(both /* ERROR cannot use */ )
- ffsend(recv /* ERROR cannot use */ )
+ ffsend(both /* ERROR "cannot use" */ )
+ ffsend(recv /* ERROR "cannot use" */ )
ffsend(send)
}
type myString string
var s1 string
g3(nil, "1", myString("2"), "3")
- g3(& /* ERROR does not match */ s1, "1", myString("2"), "3")
+ g3(& /* ERROR "does not match" */ s1, "1", myString("2"), "3")
_ = s1
type myStruct struct{x int}
// (that would indicate a slice type). Thus, generic functions cannot
// have empty type parameter lists, either. This is a syntax error.
-func h[] /* ERROR empty type parameter list */ () {}
+func h[] /* ERROR "empty type parameter list" */ () {}
func _() {
- h /* ERROR cannot index */ [] /* ERROR operand */ ()
+ h /* ERROR "cannot index" */ [] /* ERROR "operand" */ ()
}
// Generic functions must have a function body.
-func _ /* ERROR generic function is missing function body */ [P any]()
+func _ /* ERROR "generic function is missing function body" */ [P any]()
_ = min(x, 1)
_ = min(x, 1.0)
_ = min(1, 2)
- _ = min(1, 2.3 /* ERROR default type float64 .* does not match */)
+ _ = min(1, 2.3 /* ERROR "default type float64 .* does not match" */)
var y float64
_ = min(1, y)
_ = min(1.2, y)
_ = min(1.2, 3.4)
- _ = min(1.2, 3 /* ERROR default type int .* does not match */)
+ _ = min(1.2, 3 /* ERROR "default type int .* does not match" */)
var s string
_ = min(s, "foo")
// Provided type arguments always take precedence over
// inferred types.
- mixed[int, string](1.1 /* ERROR cannot use 1.1 */, "", false)
+ mixed[int, string](1.1 /* ERROR "cannot use 1.1" */, "", false)
}
func related1[Slice interface{ ~[]Elem }, Elem any](s Slice, e Elem) {}
// A type argument inferred from another explicitly provided
// type argument overrides whatever value argument type is given.
- related1[[]string](ss, 0 /* ERROR cannot use 0 */)
+ related1[[]string](ss, 0 /* ERROR "cannot use 0" */)
// A type argument may be inferred from a value argument
// and then help infer another type argument via constraint
// type inference.
related1(si, 0)
- related1(si, "foo" /* ERROR cannot use "foo" */)
+ related1(si, "foo" /* ERROR "cannot use "foo"" */)
}
func related2[Elem any, Slice interface{ []Elem }](e Elem, s Slice) {}
// last.
related2(1.2, []float64{})
related2(1.0, []int{})
- related2 /* ERROR does not satisfy */ (float64(1.0), []int{}) // TODO(gri) fix error position
+ related2 /* ERROR "does not satisfy" */ (float64(1.0), []int{}) // TODO(gri) fix error position
}
type List[P any] []P
// The 2nd type argument cannot be inferred from the first
// one because there's two possible choices: []Elem and
// List[Elem].
- related3 /* ERROR cannot infer Slice */ [int]()
+ related3 /* ERROR "cannot infer Slice" */ [int]()
}
// It cannot possibly be some other type because the receiver type is not
// instantiated with concrete types, it is standing for the parameterized
// receiver type.
-func (t T1[[ /* ERROR must be an identifier */ ]int]) m2() {}
+func (t T1[[ /* ERROR "must be an identifier" */ ]int]) m2() {}
// Note that using what looks like a predeclared identifier, say int,
// as type parameter in this situation is deceptive and considered bad
// and usually should be avoided. There are some notable exceptions; e.g.,
// sometimes it makes sense to use the identifier "copy" which happens to
// also be the name of a predeclared built-in function.
-func (t T1[int]) m3() { var _ int = 42 /* ERROR cannot use 42 .* as int */ }
+func (t T1[int]) m3() { var _ int = 42 /* ERROR "cannot use 42 .* as int" */ }
// The names of the type parameters used in a parameterized receiver
// type don't have to match the type parameter names in the declaration
// simply that such receiver type expressions perform two tasks simultaneously:
// they declare the (local) type parameters and then use them to instantiate
// the receiver type. Forgetting to provide a type parameter leads to an error.
-func (t T1 /* ERROR generic type .* without instantiation */ ) m5() {}
+func (t T1 /* ERROR "generic type .* without instantiation" */ ) m5() {}
// However, sometimes we don't need the type parameter, and thus it is
// inconvenient to have to choose a name. Since the receiver type expression
//
// type T3b[P interface{ ~unsafe.Pointer }] P
//
-// func (T3b /* ERROR invalid receiver */ [_]) m() {}
+// func (T3b /* ERROR "invalid receiver" */ [_]) m() {}
//
// type T3c[P interface{ *int | *string }] P
//
-// func (T3c /* ERROR invalid receiver */ [_]) m() {}
+// func (T3c /* ERROR "invalid receiver" */ [_]) m() {}
// indirection
func _[P any](p P) {
- _ = *p // ERROR cannot indirect p
+ _ = *p // ERROR "cannot indirect p"
}
func _[P interface{ int }](p P) {
- _ = *p // ERROR cannot indirect p
+ _ = *p // ERROR "cannot indirect p"
}
func _[P interface{ *int }](p P) {
}
func _[P interface{ *int | *string }](p P) {
- _ = *p // ERROR must have identical base types
+ _ = *p // ERROR "must have identical base types"
}
type intPtr *int
func _() {
// This assignment is invalid because the types of x1, x2 are T1(...)
// and T2(...) respectively, which are two different defined types.
- x1 = x2 // ERROR assignment
+ x1 = x2 // ERROR "assignment"
// This assignment is valid because the types of x1.f and x2.f are
// both struct { g int }; the type parameters act like type aliases
var x2a T2a
func _() {
- x1a = x2a // ERROR assignment
+ x1a = x2a // ERROR "assignment"
x1a.f = x2a.f
}
// differently depending on the type arguments, and thus we can't possibly
// consider such types identical. Consequently:
func _() {
- xint = xbool // ERROR assignment
+ xint = xbool // ERROR "assignment"
}
// Generic types cannot be used without instantiation.
-var _ T // ERROR cannot use generic type T
-var _ = T /* ERROR cannot use generic type T */ (0)
+var _ T // ERROR "cannot use generic type T"
+var _ = T /* ERROR "cannot use generic type T" */ (0)
// In type context, generic (parameterized) types cannot be parenthesized before
// being instantiated. See also NOTES entry from 12/4/2019.
-var _ (T /* ERROR cannot use generic type T */ )[ /* ERROR unexpected \[|expected ';' */ int]
+var _ (T /* ERROR "cannot use generic type T" */ )[ /* ERROR "unexpected \[|expected ';'" */ int]
// All types may be parameterized, including interfaces.
type I1[T any] interface{
}
// There is no such thing as a variadic generic type.
-type _[T ... /* ERROR invalid use of ... */ any] struct{}
+type _[T ... /* ERROR "invalid use of ..." */ any] struct{}
// Generic interfaces may be embedded as one would expect.
type I2 interface {
}
type _ struct {
- ( /* ERROR cannot parenthesize */ int8)
- ( /* ERROR cannot parenthesize */ *int16)
- *( /* ERROR cannot parenthesize */ int32)
+ ( /* ERROR "cannot parenthesize" */ int8)
+ ( /* ERROR "cannot parenthesize" */ *int16)
+ *( /* ERROR "cannot parenthesize" */ int32)
List[int]
- int8 /* ERROR int8 redeclared */
- * /* ERROR int16 redeclared */ int16
- List /* ERROR List redeclared */ [int]
+ int8 /* ERROR "int8 redeclared" */
+ * /* ERROR "int16 redeclared" */ int16
+ List /* ERROR "List redeclared" */ [int]
}
// Issue #45639: We don't allow this anymore. Keep this code
//
// // m is not defined on L (it is not "inherited" from
// // its underlying type).
-// x.m /* ERROR x.m undefined */ ()
+// x.m /* ERROR "x.m undefined" */ ()
//
// // But the properties of T, such that as that it supports
// // the operations of the types given by its type bound,
// // It is not permitted to declare a local type whose underlying
// // type is a type parameter not declared by that type declaration.
// func _[T any]() {
-// type _ T // ERROR cannot use function type parameter T as RHS in type declaration
-// type _ [_ any] T // ERROR cannot use function type parameter T as RHS in type declaration
+// type _ T // ERROR "cannot use function type parameter T as RHS in type declaration"
+// type _ [_ any] T // ERROR "cannot use function type parameter T as RHS in type declaration"
// }
// As a special case, an explicit type argument may be omitted
func _[T1 B0]() {}
func _[T1 B1[T1]]() {}
-func _[T1 B2 /* ERROR cannot use generic type .* without instantiation */ ]() {}
+func _[T1 B2 /* ERROR "cannot use generic type .* without instantiation" */ ]() {}
func _[T1, T2 B0]() {}
func _[T1 B1[T1], T2 B1[T2]]() {}
-func _[T1, T2 B2 /* ERROR cannot use generic type .* without instantiation */ ]() {}
+func _[T1, T2 B2 /* ERROR "cannot use generic type .* without instantiation" */ ]() {}
func _[T1 B0, T2 B1[T2]]() {} // here B1 applies to T2
}
var (
- _ interface /* ERROR contains type constraints */ {~int}
- _ I /* ERROR contains type constraints */
+ _ interface /* ERROR "contains type constraints" */ {~int}
+ _ I /* ERROR "contains type constraints" */
)
-func _(I /* ERROR contains type constraints */ )
-func _(x, y, z I /* ERROR contains type constraints */ )
-func _() I /* ERROR contains type constraints */
+func _(I /* ERROR "contains type constraints" */ )
+func _(x, y, z I /* ERROR "contains type constraints" */ )
+func _() I /* ERROR "contains type constraints" */
func _() {
- var _ I /* ERROR contains type constraints */
+ var _ I /* ERROR "contains type constraints" */
}
type C interface {
comparable
}
-var _ comparable /* ERROR comparable */
-var _ C /* ERROR comparable */
+var _ comparable /* ERROR "comparable" */
+var _ C /* ERROR "comparable" */
-func _(_ comparable /* ERROR comparable */ , _ C /* ERROR comparable */ )
+func _(_ comparable /* ERROR "comparable" */ , _ C /* ERROR "comparable" */ )
func _() {
- var _ comparable /* ERROR comparable */
- var _ C /* ERROR comparable */
+ var _ comparable /* ERROR "comparable" */
+ var _ C /* ERROR "comparable" */
}
// Type parameters are never const types, i.e., it's
// first place.)
func _[T interface{~int|~float64}]() {
// not valid
- const _ = T /* ERROR not constant */ (0)
- const _ T /* ERROR invalid constant type T */ = 1
+ const _ = T /* ERROR "not constant" */ (0)
+ const _ T /* ERROR "invalid constant type T" */ = 1
// valid
var _ = T(0)
// A type parameter may not be embedded in an interface;
// so it can also not be used as a constraint.
-func _[A any, B A /* ERROR cannot use a type parameter as constraint */]() {}
-func _[A any, B, C A /* ERROR cannot use a type parameter as constraint */]() {}
+func _[A any, B A /* ERROR "cannot use a type parameter as constraint" */]() {}
+func _[A any, B, C A /* ERROR "cannot use a type parameter as constraint" */]() {}
// Error messages refer to the type constraint as it appears in the source.
// (No implicit interface should be exposed.)
func _[T string](x T) T {
- return x /* ERROR constrained by string */ * x
+ return x /* ERROR "constrained by string" */ * x
}
func _[T int | string](x T) T {
- return x /* ERROR constrained by int|string */ * x
+ return x /* ERROR "constrained by int|string" */ * x
}
func (_ *T) m(a, b, c, d int) {}
-var _ I = new /* ERROR have m\(int, int, int, int\)\n\t\twant m\(int, int, \*int, int\) */ (T)
+var _ I = new /* ERROR "have m\(int, int, int, int\)\n\t\twant m\(int, int, \*int, int\)" */ (T)
// (slightly modified) test case from issue
return &Result{}, nil
}
-var ex Executor = new /* ERROR have Execute\(context\.Context, sql\.Stmt, int, \[\]sql\.NamedArg, int\) \(\*Result, error\)\n\t\twant Execute\(context\.Context, sql\.Stmt, int, \[\]sql\.NamedArg, int\) \(Result, error\) */ (myExecutor)
+var ex Executor = new /* ERROR "have Execute\(context\.Context, sql\.Stmt, int, \[\]sql\.NamedArg, int\) \(\*Result, error\)\n\t\twant Execute\(context\.Context, sql\.Stmt, int, \[\]sql\.NamedArg, int\) \(Result, error\)" */ (myExecutor)
package issue20583
const (
- _ = 6e886451608 /* ERROR malformed constant */ /2
- _ = 6e886451608i /* ERROR malformed constant */ /2
- _ = 0 * 1e+1000000000 // ERROR malformed constant
+ _ = 6e886451608 /* ERROR "malformed constant" */ /2
+ _ = 6e886451608i /* ERROR "malformed constant" */ /2
+ _ = 0 * 1e+1000000000 // ERROR "malformed constant"
x = 1e100000000
- _ = x*x*x*x*x*x* /* ERROR not representable */ x
+ _ = x*x*x*x*x*x* /* ERROR "not representable" */ x
)
T11 = T
)
-func (T9 /* ERROR invalid receiver type \*\*T */ ) m9() {}
-func _() { (T{}).m9 /* ERROR has no field or method m9 */ () }
-func _() { (&T{}).m9 /* ERROR has no field or method m9 */ () }
+func (T9 /* ERROR "invalid receiver type \*\*T" */ ) m9() {}
+func _() { (T{}).m9 /* ERROR "has no field or method m9" */ () }
+func _() { (&T{}).m9 /* ERROR "has no field or method m9" */ () }
package p
// crash 1
-type nt1[_ any]interface{g /* ERROR undefined */ }
-type ph1[e nt1[e],g(d /* ERROR undefined */ )]s /* ERROR undefined */
-func(*ph1[e,e /* ERROR redeclared */ ])h(d /* ERROR undefined */ )
+type nt1[_ any]interface{g /* ERROR "undefined" */ }
+type ph1[e nt1[e],g(d /* ERROR "undefined" */ )]s /* ERROR "undefined" */
+func(*ph1[e,e /* ERROR "redeclared" */ ])h(d /* ERROR "undefined" */ )
// crash 2
// Disabled: empty []'s are now syntax errors. This example leads to too many follow-on errors.
-// type Numeric2 interface{t2 /* ERROR not a type */ }
-// func t2[T Numeric2](s[]T){0 /* ERROR not a type */ []{s /* ERROR cannot index */ [0][0]}}
+// type Numeric2 interface{t2 /* ERROR "not a type" */ }
+// func t2[T Numeric2](s[]T){0 /* ERROR "not a type */ []{s /* ERROR cannot index" */ [0][0]}}
// crash 3
-type t3 *interface{ t3.p /* ERROR t3.p is not a type */ }
+type t3 *interface{ t3.p /* ERROR "t3.p is not a type" */ }
// crash 4
-type Numeric4 interface{t4 /* ERROR not a type */ }
-func t4[T Numeric4](s[]T){if( /* ERROR non-boolean */ 0){*s /* ERROR cannot indirect */ [0]}}
+type Numeric4 interface{t4 /* ERROR "not a type" */ }
+func t4[T Numeric4](s[]T){if( /* ERROR "non-boolean" */ 0){*s /* ERROR "cannot indirect" */ [0]}}
// crash 7
type foo7 interface { bar() }
func main7() { var _ foo7 = x7[int]{} }
// crash 8
-type foo8[A any] interface { ~A /* ERROR cannot be a type parameter */ }
+type foo8[A any] interface { ~A /* ERROR "cannot be a type parameter" */ }
func bar8[A foo8[A]](a A) {}
// crash 9
-type foo9[A any] interface { foo9 /* ERROR invalid recursive type */ [A] }
+type foo9[A any] interface { foo9 /* ERROR "invalid recursive type" */ [A] }
func _() { var _ = new(foo9[int]) }
// crash 12
-var u /* ERROR cycle */ , i [func /* ERROR used as value */ /* ERROR used as value */ (u, c /* ERROR undefined */ /* ERROR undefined */ ) {}(0, len /* ERROR must be called */ /* ERROR must be called */ )]c /* ERROR undefined */ /* ERROR undefined */
+var u /* ERROR "cycle" */ , i [func /* ERROR "used as value" */ /* ERROR "used as value" */ (u, c /* ERROR "undefined" */ /* ERROR "undefined" */ ) {}(0, len /* ERROR "must be called" */ /* ERROR "must be called" */ )]c /* ERROR "undefined" */ /* ERROR "undefined" */
// crash 15
-func y15() { var a /* ERROR declared and not used */ interface{ p() } = G15[string]{} }
-type G15[X any] s /* ERROR undefined */
-func (G15 /* ERROR generic type .* without instantiation */ ) p()
+func y15() { var a /* ERROR "declared and not used" */ interface{ p() } = G15[string]{} }
+type G15[X any] s /* ERROR "undefined" */
+func (G15 /* ERROR "generic type .* without instantiation" */ ) p()
// crash 16
-type Foo16[T any] r16 /* ERROR not a type */
+type Foo16[T any] r16 /* ERROR "not a type" */
func r16[T any]() Foo16[Foo16[T]] { panic(0) }
// crash 17
type Y17 interface{ c() }
type Z17 interface {
c() Y17
- Y17 /* ERROR duplicate method */
+ Y17 /* ERROR "duplicate method" */
}
func F17[T Z17](T) {}
// crash 18
-type o18[T any] []func(_ o18[[]_ /* ERROR cannot use _ */ ])
+type o18[T any] []func(_ o18[[]_ /* ERROR "cannot use _" */ ])
// crash 19
-type Z19 [][[]Z19{}[0][0]]c19 /* ERROR undefined */
+type Z19 [][[]Z19{}[0][0]]c19 /* ERROR "undefined" */
// crash 20
-type Z20 /* ERROR invalid recursive type */ interface{ Z20 }
-func F20[t Z20]() { F20(t /* ERROR invalid composite literal type */ {}) }
+type Z20 /* ERROR "invalid recursive type" */ interface{ Z20 }
+func F20[t Z20]() { F20(t /* ERROR "invalid composite literal type" */ {}) }
// crash 21
-type Z21 /* ERROR invalid recursive type */ interface{ Z21 }
-func F21[T Z21]() { ( /* ERROR not used */ F21[Z21]) }
+type Z21 /* ERROR "invalid recursive type" */ interface{ Z21 }
+func F21[T Z21]() { ( /* ERROR "not used" */ F21[Z21]) }
// crash 24
-type T24[P any] P // ERROR cannot use a type parameter as RHS in type declaration
-func (r T24[P]) m() { T24 /* ERROR without instantiation */ .m() }
+type T24[P any] P // ERROR "cannot use a type parameter as RHS in type declaration"
+func (r T24[P]) m() { T24 /* ERROR "without instantiation" */ .m() }
// crash 25
type T25[A any] int
func (t T25[A]) m1() {}
-var x T25 /* ERROR without instantiation */ .m1
+var x T25 /* ERROR "without instantiation" */ .m1
// crash 26
-type T26 = interface{ F26[ /* ERROR interface method must have no type parameters */ Z any]() }
-func F26[Z any]() T26 { return F26[] /* ERROR operand */ }
+type T26 = interface{ F26[ /* ERROR "interface method must have no type parameters" */ Z any]() }
+func F26[Z any]() T26 { return F26[] /* ERROR "operand" */ }
// crash 27
-func e27[T any]() interface{ x27 /* ERROR not a type */ } { panic(0) }
-func x27() { e27 /* ERROR cannot infer T */ () }
+func e27[T any]() interface{ x27 /* ERROR "not a type" */ } { panic(0) }
+func x27() { e27 /* ERROR "cannot infer T" */ () }
type T[_ any] struct {}
-func (T /* ERROR instantiation */ ) m()
+func (T /* ERROR "instantiation" */ ) m()
func _() {
var x interface { m() }
}
func Add1[T Number1](a, b T) T {
- return a /* ERROR not defined */ + b
+ return a /* ERROR "not defined" */ + b
}
type Number2 interface {
func _() {
_ = T0(0)
- _ = T1 /* ERROR cannot use interface T1 in conversion */ (1)
- _ = T2 /* ERROR cannot use interface T2 in conversion */ (2)
- _ = T3 /* ERROR cannot use interface T3 in conversion */ (3)
+ _ = T1 /* ERROR "cannot use interface T1 in conversion" */ (1)
+ _ = T2 /* ERROR "cannot use interface T2 in conversion" */ (2)
+ _ = T3 /* ERROR "cannot use interface T3 in conversion" */ (3)
}
// A constraint must be an interface; it cannot
// be a type parameter, for instance.
-func _[A interface{ ~int }, B A /* ERROR cannot use a type parameter as constraint */ ]() {}
+func _[A interface{ ~int }, B A /* ERROR "cannot use a type parameter as constraint" */ ]() {}
func f1[T1, T2 any](T1, T2, struct{a T1; b T2}) {}
func _() {
- f1(42, string("foo"), struct /* ERROR does not match inferred type struct\{a int; b string\} */ {a, b int}{})
+ f1(42, string("foo"), struct /* ERROR "does not match inferred type struct\{a int; b string\}" */ {a, b int}{})
}
// simplified test case from issue
func f2[T any](_ []T, _ func(T)) {}
func _() {
- f2([]string{}, func /* ERROR does not match inferred type func\(string\) */ (f []byte) {})
+ f2([]string{}, func /* ERROR "does not match inferred type func\(string\)" */ (f []byte) {})
}
\r
func _() {\r
f[int, Optional[int], Optional[int]]()\r
- _ = f[int, Optional[int], Optional /* ERROR does not satisfy Box */ [string]]\r
- _ = f[int, Optional[int], Optional /* ERROR Optional.* does not satisfy Box.* */ [string]]\r
+ _ = f[int, Optional[int], Optional /* ERROR "does not satisfy Box" */ [string]]\r
+ _ = f[int, Optional[int], Optional /* ERROR "Optional.* does not satisfy Box.*" */ [string]]\r
}\r
// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639).
// type T[P any] P
-// type A = T // ERROR cannot use generic type
+// type A = T // ERROR "cannot use generic type"
// var x A[int]
// var _ A
//
// type B = T[int]
// var y B = x
-// var _ B /* ERROR not a generic type */ [int]
+// var _ B /* ERROR "not a generic type" */ [int]
// test case from issue
type Vector[T any] []T
-type VectorAlias = Vector // ERROR cannot use generic type
+type VectorAlias = Vector // ERROR "cannot use generic type"
var v Vector[int]
_ E1[T1]
}
-type T2 /* ERROR invalid recursive type */ struct {
+type T2 /* ERROR "invalid recursive type" */ struct {
_ E2[T2]
}
_ E3[T3]
}
-type T4 /* ERROR invalid recursive type */ [10]E5[T4]
+type T4 /* ERROR "invalid recursive type" */ [10]E5[T4]
type T5 struct {
_ E0[E2[T5]]
_ E0[[]E2[E0[E2[E2[T8]]]]]
}
-type T9 /* ERROR invalid recursive type */ [10]E2[E5[E2[T9]]]
+type T9 /* ERROR "invalid recursive type" */ [10]E2[E5[E2[T9]]]
type T10 [10]E2[E5[E2[func(T10)]]]
package p
type T[P any] interface{
- P // ERROR term cannot be a type parameter
+ P // ERROR "term cannot be a type parameter"
}
func _() {
var lru LRU[int, string]
NewCache[int, string](&lru)
- NewCache(& /* ERROR does not match policy\[K, V\] \(cannot infer K and V\) */ lru)
+ NewCache(& /* ERROR "does not match policy\[K, V\] \(cannot infer K and V\)" */ lru)
}
package p
func _() {
- NewS /* ERROR cannot infer T */ ().M()
+ NewS /* ERROR "cannot infer T" */ ().M()
}
type S struct {}
func NewS[T any]() *S { panic(0) }
-func (_ *S /* ERROR S is not a generic type */ [T]) M()
+func (_ *S /* ERROR "S is not a generic type" */ [T]) M()
func _() {
var x interface{}
switch t := x.(type) {
- case S /* ERROR cannot use generic type */ :
+ case S /* ERROR "cannot use generic type" */ :
t.m()
}
}
func f[T number]() {}
func _() {
- _ = f[int /* ERROR int does not satisfy number \(number mentions int, but int is not in the type set of number\)*/]
+ _ = f[int /* ERROR "int does not satisfy number \(number mentions int, but int is not in the type set of number\)" */]
}
func g[_, _ any]() {}
func _() {
- _ = f[T /* ERROR without instantiation */ ]
- _ = g[T /* ERROR without instantiation */ , T /* ERROR without instantiation */ ]
+ _ = f[T /* ERROR "without instantiation" */ ]
+ _ = g[T /* ERROR "without instantiation" */ , T /* ERROR "without instantiation" */ ]
}
// Test case from issue.
-type Nat /* ERROR invalid recursive type */ interface {
+type Nat /* ERROR "invalid recursive type" */ interface {
Zero|Succ
}
}
type _ struct {
- f I1 // ERROR interface is .* comparable
+ f I1 // ERROR "interface is .* comparable"
}
type _ struct {
- comparable // ERROR interface is .* comparable
+ comparable // ERROR "interface is .* comparable"
}
type _ struct{
- I1 // ERROR interface is .* comparable
+ I1 // ERROR "interface is .* comparable"
}
type _ struct{
- I2 // ERROR interface contains type constraints
+ I2 // ERROR "interface contains type constraints"
}
type _ struct{
- I3 // ERROR interface contains type constraints
+ I3 // ERROR "interface contains type constraints"
}
// General composite types.
type (
- _ [10]I1 // ERROR interface is .* comparable
- _ [10]I2 // ERROR interface contains type constraints
+ _ [10]I1 // ERROR "interface is .* comparable"
+ _ [10]I2 // ERROR "interface contains type constraints"
- _ []I1 // ERROR interface is .* comparable
- _ []I2 // ERROR interface contains type constraints
+ _ []I1 // ERROR "interface is .* comparable"
+ _ []I2 // ERROR "interface contains type constraints"
- _ *I3 // ERROR interface contains type constraints
- _ map[I1 /* ERROR interface is .* comparable */ ]I2 // ERROR interface contains type constraints
- _ chan I3 // ERROR interface contains type constraints
- _ func(I1 /* ERROR interface is .* comparable */ )
- _ func() I2 // ERROR interface contains type constraints
+ _ *I3 // ERROR "interface contains type constraints"
+ _ map[I1 /* ERROR "interface is .* comparable" */ ]I2 // ERROR "interface contains type constraints"
+ _ chan I3 // ERROR "interface contains type constraints"
+ _ func(I1 /* ERROR "interface is .* comparable" */ )
+ _ func() I2 // ERROR "interface contains type constraints"
)
// Other cases.
-var _ = [...]I3 /* ERROR interface contains type constraints */ {}
+var _ = [...]I3 /* ERROR "interface contains type constraints" */ {}
func _(x interface{}) {
- _ = x.(I3 /* ERROR interface contains type constraints */ )
+ _ = x.(I3 /* ERROR "interface contains type constraints" */ )
}
type T1[_ any] struct{}
type T3[_, _, _ any] struct{}
-var _ T1[I2 /* ERROR interface contains type constraints */ ]
-var _ T3[int, I2 /* ERROR interface contains type constraints */ , float32]
+var _ T1[I2 /* ERROR "interface contains type constraints" */ ]
+var _ T3[int, I2 /* ERROR "interface contains type constraints" */ , float32]
func f1[_ any]() int { panic(0) }
-var _ = f1[I2 /* ERROR interface contains type constraints */ ]()
+var _ = f1[I2 /* ERROR "interface contains type constraints" */ ]()
func f3[_, _, _ any]() int { panic(0) }
-var _ = f3[int, I2 /* ERROR interface contains type constraints */ , float32]()
+var _ = f3[int, I2 /* ERROR "interface contains type constraints" */ , float32]()
func _(x interface{}) {
switch x.(type) {
- case I2 /* ERROR interface contains type constraints */ :
+ case I2 /* ERROR "interface contains type constraints" */ :
}
}
package issue42695
-const _ = 6e5518446744 // ERROR malformed constant
-const _ uint8 = 6e5518446744 // ERROR malformed constant
+const _ = 6e5518446744 // ERROR "malformed constant"
+const _ uint8 = 6e5518446744 // ERROR "malformed constant"
-var _ = 6e5518446744 // ERROR malformed constant
-var _ uint8 = 6e5518446744 // ERROR malformed constant
+var _ = 6e5518446744 // ERROR "malformed constant"
+var _ uint8 = 6e5518446744 // ERROR "malformed constant"
func f(x int) int {
- return x + 6e5518446744 // ERROR malformed constant
+ return x + 6e5518446744 // ERROR "malformed constant"
}
-var _ = f(6e5518446744 /* ERROR malformed constant */ )
+var _ = f(6e5518446744 /* ERROR "malformed constant" */ )
switch x.(type) {
case T:
- case T /* ERROR duplicate case */ :
+ case T /* ERROR "duplicate case" */ :
}
}
}
}
-func _(x constraint /* ERROR contains type constraints */ ) {
+func _(x constraint /* ERROR "contains type constraints" */ ) {
switch x.(type) { // no need to report another error
}
}
)
var (
- _ comparable // ERROR cannot use type comparable outside a type constraint: interface is \(or embeds\) comparable
- _ T1 // ERROR cannot use type T1 outside a type constraint: interface is \(or embeds\) comparable
- _ T2 // ERROR cannot use type T2 outside a type constraint: interface contains type constraints
+ _ comparable // ERROR "cannot use type comparable outside a type constraint: interface is \(or embeds\) comparable"
+ _ T1 // ERROR "cannot use type T1 outside a type constraint: interface is \(or embeds\) comparable"
+ _ T2 // ERROR "cannot use type T2 outside a type constraint: interface contains type constraints"
)
// Check that there is only one error (no follow-on errors).
package p
-var _ = [ ... /* ERROR invalid use of \[...\] array */ ]byte("foo")
\ No newline at end of file
+var _ = [ ... /* ERROR "invalid use of \[...\] array" */ ]byte("foo")
\ No newline at end of file
package p
func _() {
- a, b, b /* ERROR b repeated on left side of := */ := 1, 2, 3
+ a, b, b /* ERROR "b repeated on left side of :=" */ := 1, 2, 3
_ = a
_ = b
}
func _() {
var b int
- a, b, b /* ERROR b repeated on left side of := */ := 1, 2, 3
+ a, b, b /* ERROR "b repeated on left side of :=" */ := 1, 2, 3
_ = a
_ = b
}
func _() {
var a []int
- a /* ERROR non-name .* on left side of := */ [0], b := 1, 2
+ a /* ERROR "non-name .* on left side of :=" */ [0], b := 1, 2
_ = a
_ = b
}
func _() {
var a int
- a, a /* ERROR a repeated on left side of := */ := 1, 2
+ a, a /* ERROR "a repeated on left side of :=" */ := 1, 2
_ = a
}
func _() {
var a, b int
- a, b := /* ERROR no new variables on left side of := */ 1, 2
+ a, b := /* ERROR "no new variables on left side of :=" */ 1, 2
_ = a
_ = b
}
package p
-import . "/foo" // ERROR could not import \/foo
+import . "/foo" // ERROR "could not import \/foo"
func _() {
// want an error even if the switch is empty
var a struct{ _ func() }
- switch a /* ERROR cannot switch on a */ {
+ switch a /* ERROR "cannot switch on a" */ {
}
- switch a /* ERROR cannot switch on a */ {
+ switch a /* ERROR "cannot switch on a" */ {
case a: // no follow-on error here
}
}
switch (func())(nil) {
- case f /* ERROR invalid case f in switch on .* \(func can only be compared to nil\) */ :
+ case f /* ERROR "invalid case f in switch on .* \(func can only be compared to nil\)" */ :
}
- switch nil /* ERROR use of untyped nil in switch expression */ {
+ switch nil /* ERROR "use of untyped nil in switch expression" */ {
}
// this is ok
package p
-var _ = int(0 /* ERROR invalid use of \.\.\. in conversion to int */ ...)
+var _ = int(0 /* ERROR "invalid use of \.\.\. in conversion to int" */ ...)
// test case from issue
var (
x = []string{"a", "b"}
- _ = M(x /* ERROR invalid use of \.\.\. in conversion to M */ ...)
+ _ = M(x /* ERROR "invalid use of \.\.\. in conversion to M" */ ...)
)
package p
-var _ = new(- /* ERROR not a type */ 1)
-var _ = new(1 /* ERROR not a type */ + 1)
+var _ = new(- /* ERROR "not a type" */ 1)
+var _ = new(1 /* ERROR "not a type" */ + 1)
package p
-import ; // ERROR missing import path
-import "" // ERROR invalid import path \(empty string\)
+import ; // ERROR "missing import path"
+import "" // ERROR "invalid import path \(empty string\)"
import
-var /* ERROR missing import path */ _ int
-import .; // ERROR missing import path
-import 'x' // ERROR import path must be a string
+var /* ERROR "missing import path" */ _ int
+import .; // ERROR "missing import path"
+import 'x' // ERROR "import path must be a string"
var _ int
-import /* ERROR imports must appear before other declarations */ _ "math"
+import /* ERROR "imports must appear before other declarations" */ _ "math"
// Don't repeat previous error for each immediately following import ...
import ()
-import (.) // ERROR missing import path
+import (.) // ERROR "missing import path"
import (
"fmt"
.
-) // ERROR missing import path
+) // ERROR "missing import path"
// ... but remind with error again if we start a new import section after
// other declarations
var _ = fmt.Println
-import /* ERROR imports must appear before other declarations */ _ "math"
+import /* ERROR "imports must appear before other declarations" */ _ "math"
import _ "math"
type (
_ [L]struct{}
- _ [A /* ERROR undefined array length A or missing type constraint */ ]struct{}
- _ [B /* ERROR invalid array length B */ ]struct{}
+ _ [A /* ERROR "undefined array length A or missing type constraint" */ ]struct{}
+ _ [B /* ERROR "invalid array length B" */ ]struct{}
_[A any] struct{}
B int
type C5[T any] interface{ ~chan T | <-chan T }
func _[T any](ch T) {
- <-ch // ERROR cannot receive from ch .* \(no core type\)
+ <-ch // ERROR "cannot receive from ch .* \(no core type\)"
}
func _[T C0](ch T) {
- <-ch // ERROR cannot receive from non-channel ch
+ <-ch // ERROR "cannot receive from non-channel ch"
}
func _[T C1](ch T) {
}
func _[T C3](ch T) {
- <-ch // ERROR cannot receive from ch .* \(no core type\)
+ <-ch // ERROR "cannot receive from ch .* \(no core type\)"
}
func _[T C4](ch T) {
- <-ch // ERROR cannot receive from send-only channel
+ <-ch // ERROR "cannot receive from send-only channel"
}
func _[T C5[X], X any](ch T, x X) {
package p
var s uint
-var _ = string(1 /* ERROR shifted operand 1 .* must be integer */ << s)
+var _ = string(1 /* ERROR "shifted operand 1 .* must be integer" */ << s)
package p
-type Builder /* ERROR invalid recursive type */ [T interface{ struct{ Builder[T] } }] struct{}
+type Builder /* ERROR "invalid recursive type" */ [T interface{ struct{ Builder[T] } }] struct{}
type myBuilder struct {
Builder[myBuilder]
}
type N[T any] struct{}
-var _ N [] // ERROR expected type argument list
+var _ N [] // ERROR "expected type argument list"
type I interface {
~[]int
// // It is not permitted to declare a local type whose underlying
// // type is a type parameters not declared by that type declaration.
// func _[T any]() {
-// type _ T // ERROR cannot use function type parameter T as RHS in type declaration
-// type _ [_ any] T // ERROR cannot use function type parameter T as RHS in type declaration
+// type _ T // ERROR "cannot use function type parameter T as RHS in type declaration"
+// type _ [_ any] T // ERROR "cannot use function type parameter T as RHS in type declaration"
// }
func _(ch chan int) { f1(ch) }
func _(ch <-chan int) { f1(ch) }
-func _(ch chan<- int) { f1 /* ERROR chan<- int does not satisfy chan int \| <-chan int */ (ch) }
+func _(ch chan<- int) { f1 /* ERROR "chan<- int does not satisfy chan int \| <-chan int" */ (ch) }
func f2[T any, C chan T | chan<- T](ch C) {}
func _(ch chan int) { f2(ch) }
-func _(ch <-chan int) { f2 /* ERROR <-chan int does not satisfy chan int \| chan<- int */ (ch) }
+func _(ch <-chan int) { f2 /* ERROR "<-chan int does not satisfy chan int \| chan<- int" */ (ch) }
func _(ch chan<- int) { f2(ch) }
package p
-type _ comparable // ERROR predeclared comparable
+type _ comparable // ERROR "predeclared comparable"
func _() {
// a should be used, despite the parser error below.
var a []int
- var _ = a[] // ERROR expected operand
+ var _ = a[] // ERROR "expected operand"
}
package p
// test case 1
-type T /* ERROR invalid recursive type */ [U interface{ M() T[U] }] int
+type T /* ERROR "invalid recursive type" */ [U interface{ M() T[U] }] int
type X int
func (X) M() T[X] { return 0 }
// test case 2
-type A /* ERROR invalid recursive type */ [T interface{ A[T] }] interface{}
+type A /* ERROR "invalid recursive type" */ [T interface{ A[T] }] interface{}
// test case 3
-type A2 /* ERROR invalid recursive type */ [U interface{ A2[U] }] interface{ M() A2[U] }
+type A2 /* ERROR "invalid recursive type" */ [U interface{ A2[U] }] interface{ M() A2[U] }
type I interface{ A2[I]; M() A2[I] }
var f4 func(T4)
func _() {
- f1 = T1 /* ERROR func\(T1, int\) */ .m
- f2 = T2 /* ERROR func\(t T2, x int\) */ .m
- f3 = T3 /* ERROR func\(T3, int\) */ .m
- f4 = T4 /* ERROR func\(_ T4, x int\) */ .m
+ f1 = T1 /* ERROR "func\(T1, int\)" */ .m
+ f2 = T2 /* ERROR "func\(t T2, x int\)" */ .m
+ f3 = T3 /* ERROR "func\(T3, int\)" */ .m
+ f4 = T4 /* ERROR "func\(_ T4, x int\)" */ .m
}
type Mer interface { M() }
func F[T Mer](p *T) {
- p.M /* ERROR p\.M undefined */ ()
+ p.M /* ERROR "p\.M undefined" */ ()
}
type MyMer int
type C5[T any] interface{ ~chan T | chan<- T }
func _[T any](ch T) {
- ch <- /* ERROR cannot send to ch .* no core type */ 0
+ ch <- /* ERROR "cannot send to ch .* no core type" */ 0
}
func _[T C0](ch T) {
- ch <- /* ERROR cannot send to non-channel */ 0
+ ch <- /* ERROR "cannot send to non-channel" */ 0
}
func _[T C1](ch T) {
}
func _[T C2](ch T) {
- ch <-/* ERROR cannot send to receive-only channel */ 0
+ ch <-/* ERROR "cannot send to receive-only channel" */ 0
}
func _[T C3](ch T) {
- ch <- /* ERROR cannot send to ch .* no core type */ 0
+ ch <- /* ERROR "cannot send to ch .* no core type" */ 0
}
func _[T C4](ch T) {
type (
_[P any] interface{ *P | []P | chan P | map[string]P }
- _[P any] interface{ P /* ERROR term cannot be a type parameter */ }
- _[P any] interface{ ~P /* ERROR type in term ~P cannot be a type parameter */ }
- _[P any] interface{ int | P /* ERROR term cannot be a type parameter */ }
- _[P any] interface{ int | ~P /* ERROR type in term ~P cannot be a type parameter */ }
+ _[P any] interface{ P /* ERROR "term cannot be a type parameter" */ }
+ _[P any] interface{ ~P /* ERROR "type in term ~P cannot be a type parameter" */ }
+ _[P any] interface{ int | P /* ERROR "term cannot be a type parameter" */ }
+ _[P any] interface{ int | ~P /* ERROR "type in term ~P cannot be a type parameter" */ }
)
func _[P any]() {
type (
_[P any] interface{ *P | []P | chan P | map[string]P }
- _[P any] interface{ P /* ERROR term cannot be a type parameter */ }
- _[P any] interface{ ~P /* ERROR type in term ~P cannot be a type parameter */ }
- _[P any] interface{ int | P /* ERROR term cannot be a type parameter */ }
- _[P any] interface{ int | ~P /* ERROR type in term ~P cannot be a type parameter */ }
+ _[P any] interface{ P /* ERROR "term cannot be a type parameter" */ }
+ _[P any] interface{ ~P /* ERROR "type in term ~P cannot be a type parameter" */ }
+ _[P any] interface{ int | P /* ERROR "term cannot be a type parameter" */ }
+ _[P any] interface{ int | ~P /* ERROR "type in term ~P cannot be a type parameter" */ }
_ interface{ *P | []P | chan P | map[string]P }
- _ interface{ P /* ERROR term cannot be a type parameter */ }
- _ interface{ ~P /* ERROR type in term ~P cannot be a type parameter */ }
- _ interface{ int | P /* ERROR term cannot be a type parameter */ }
- _ interface{ int | ~P /* ERROR type in term ~P cannot be a type parameter */ }
+ _ interface{ P /* ERROR "term cannot be a type parameter" */ }
+ _ interface{ ~P /* ERROR "type in term ~P cannot be a type parameter" */ }
+ _ interface{ int | P /* ERROR "term cannot be a type parameter" */ }
+ _ interface{ int | ~P /* ERROR "type in term ~P cannot be a type parameter" */ }
)
}
func _[P any, Q interface{ *P | []P | chan P | map[string]P }]() {}
-func _[P any, Q interface{ P /* ERROR term cannot be a type parameter */ }]() {}
-func _[P any, Q interface{ ~P /* ERROR type in term ~P cannot be a type parameter */ }]() {}
-func _[P any, Q interface{ int | P /* ERROR term cannot be a type parameter */ }]() {}
-func _[P any, Q interface{ int | ~P /* ERROR type in term ~P cannot be a type parameter */ }]() {}
+func _[P any, Q interface{ P /* ERROR "term cannot be a type parameter" */ }]() {}
+func _[P any, Q interface{ ~P /* ERROR "type in term ~P cannot be a type parameter" */ }]() {}
+func _[P any, Q interface{ int | P /* ERROR "term cannot be a type parameter" */ }]() {}
+func _[P any, Q interface{ int | ~P /* ERROR "type in term ~P cannot be a type parameter" */ }]() {}
_ = f[int]
_ = f[P]
_ = f[Q]
- _ = f[func /* ERROR does not satisfy comparable */ ()]
- _ = f[R /* ERROR R does not satisfy comparable */ ]
+ _ = f[func /* ERROR "does not satisfy comparable" */ ()]
+ _ = f[R /* ERROR "R does not satisfy comparable" */ ]
_ = g[int]
- _ = g[P /* ERROR P does not satisfy interface{interface{comparable; ~int \| ~string} */ ]
+ _ = g[P /* ERROR "P does not satisfy interface{interface{comparable; ~int \| ~string}" */ ]
_ = g[Q]
- _ = g[func /* ERROR func\(\) does not satisfy interface{interface{comparable; ~int \| ~string}} */ ()]
- _ = g[R /* ERROR R does not satisfy interface{interface{comparable; ~int \| ~string} */ ]
+ _ = g[func /* ERROR "func\(\) does not satisfy interface{interface{comparable; ~int \| ~string}}" */ ()]
+ _ = g[R /* ERROR "R does not satisfy interface{interface{comparable; ~int \| ~string}" */ ]
}
x.m()
// (&x).m doesn't exist because &x is of type *P
// and pointers to type parameters don't have methods
- (&x).m /* ERROR type \*P is pointer to type parameter, not type parameter */ ()
+ (&x).m /* ERROR "type \*P is pointer to type parameter, not type parameter" */ ()
}
func _(x *T2) {
// x.m doesn't exists because x is of type *T2
// and pointers to interfaces don't have methods
- x.m /* ERROR type \*T2 is pointer to interface, not interface */()
+ x.m /* ERROR "type \*T2 is pointer to interface, not interface" */()
}
// Test case 1 from issue
// parameterized types with self-recursive constraints
type (
- T1 /* ERROR invalid recursive type */ [P T1[P]] interface{}
- T2 /* ERROR invalid recursive type */ [P, Q T2[P, Q]] interface{}
+ T1 /* ERROR "invalid recursive type" */ [P T1[P]] interface{}
+ T2 /* ERROR "invalid recursive type" */ [P, Q T2[P, Q]] interface{}
T3[P T2[P, Q], Q interface{ ~string }] interface{}
- T4a /* ERROR invalid recursive type */ [P T4a[P]] interface{ ~int }
- T4b /* ERROR invalid recursive type */ [P T4b[int]] interface{ ~int }
- T4c /* ERROR invalid recursive type */ [P T4c[string]] interface{ ~int }
+ T4a /* ERROR "invalid recursive type" */ [P T4a[P]] interface{ ~int }
+ T4b /* ERROR "invalid recursive type" */ [P T4b[int]] interface{ ~int }
+ T4c /* ERROR "invalid recursive type" */ [P T4c[string]] interface{ ~int }
// mutually recursive constraints
- T5 /* ERROR invalid recursive type */ [P T6[P]] interface{ int }
+ T5 /* ERROR "invalid recursive type" */ [P T6[P]] interface{ int }
T6[P T5[P]] interface{ int }
)
// test case from issue
-type Eq /* ERROR invalid recursive type */ [a Eq[a]] interface {
+type Eq /* ERROR "invalid recursive type" */ [a Eq[a]] interface {
Equal(that a) bool
}
package p
-type T[P /* ERROR type parameter requires go1\.18 or later */ any /* ERROR predeclared any requires go1\.18 or later */] struct{}
+type T[P /* ERROR "type parameter requires go1\.18 or later" */ any /* ERROR "predeclared any requires go1\.18 or later" */] struct{}
// for init (and main, but we're not in package main) we should only get one error
-func init[P /* ERROR func init must have no type parameters */ any /* ERROR predeclared any requires go1\.18 or later */]() {
+func init[P /* ERROR "func init must have no type parameters" */ any /* ERROR "predeclared any requires go1\.18 or later" */]() {
}
-func main[P /* ERROR type parameter requires go1\.18 or later */ any /* ERROR predeclared any requires go1\.18 or later */]() {
+func main[P /* ERROR "type parameter requires go1\.18 or later" */ any /* ERROR "predeclared any requires go1\.18 or later" */]() {
}
-func f[P /* ERROR type parameter requires go1\.18 or later */ any /* ERROR predeclared any requires go1\.18 or later */](x P) {
- var _ T[ /* ERROR type instantiation requires go1\.18 or later */ int]
- var _ (T[ /* ERROR type instantiation requires go1\.18 or later */ int])
- _ = T[ /* ERROR type instantiation requires go1\.18 or later */ int]{}
- _ = T[ /* ERROR type instantiation requires go1\.18 or later */ int](struct{}{})
+func f[P /* ERROR "type parameter requires go1\.18 or later" */ any /* ERROR "predeclared any requires go1\.18 or later" */](x P) {
+ var _ T[ /* ERROR "type instantiation requires go1\.18 or later" */ int]
+ var _ (T[ /* ERROR "type instantiation requires go1\.18 or later" */ int])
+ _ = T[ /* ERROR "type instantiation requires go1\.18 or later" */ int]{}
+ _ = T[ /* ERROR "type instantiation requires go1\.18 or later" */ int](struct{}{})
}
-func (T[ /* ERROR type instantiation requires go1\.18 or later */ P]) g(x int) {
- f[ /* ERROR function instantiation requires go1\.18 or later */ int](0) // explicit instantiation
- (f[ /* ERROR function instantiation requires go1\.18 or later */ int])(0) // parentheses (different code path)
- f( /* ERROR implicit function instantiation requires go1\.18 or later */ x) // implicit instantiation
+func (T[ /* ERROR "type instantiation requires go1\.18 or later" */ P]) g(x int) {
+ f[ /* ERROR "function instantiation requires go1\.18 or later" */ int](0) // explicit instantiation
+ (f[ /* ERROR "function instantiation requires go1\.18 or later" */ int])(0) // parentheses (different code path)
+ f( /* ERROR "implicit function instantiation requires go1\.18 or later" */ x) // implicit instantiation
}
type C1 interface {
- comparable // ERROR predeclared comparable requires go1\.18 or later
+ comparable // ERROR "predeclared comparable requires go1\.18 or later"
}
type C2 interface {
- comparable // ERROR predeclared comparable requires go1\.18 or later
- int // ERROR embedding non-interface type int requires go1\.18 or later
- ~ /* ERROR embedding interface element ~int requires go1\.18 or later */ int
- int /* ERROR embedding interface element int \| ~string requires go1\.18 or later */ | ~string
+ comparable // ERROR "predeclared comparable requires go1\.18 or later"
+ int // ERROR "embedding non-interface type int requires go1\.18 or later"
+ ~ /* ERROR "embedding interface element ~int requires go1\.18 or later" */ int
+ int /* ERROR "embedding interface element int \| ~string requires go1\.18 or later" */ | ~string
}
type _ interface {
}
type (
- _ comparable // ERROR predeclared comparable requires go1\.18 or later
+ _ comparable // ERROR "predeclared comparable requires go1\.18 or later"
// errors for these were reported with their declaration
_ C1
_ C2
- _ = comparable // ERROR predeclared comparable requires go1\.18 or later
+ _ = comparable // ERROR "predeclared comparable requires go1\.18 or later"
// errors for these were reported with their declaration
_ = C1
_ = C2
func (T[P]) m1()
-type A1 = T // ERROR cannot use generic type
+type A1 = T // ERROR "cannot use generic type"
func (A1[P]) m2() {}
type A2 = T[int]
-func (A2 /* ERROR cannot define new methods on instantiated type T\[int\] */) m3() {}
-func (_ /* ERROR cannot define new methods on instantiated type T\[int\] */ A2) m4() {}
+func (A2 /* ERROR "cannot define new methods on instantiated type T\[int\]" */) m3() {}
+func (_ /* ERROR "cannot define new methods on instantiated type T\[int\]" */ A2) m4() {}
func (T[int]) m5() {} // int is the type parameter name, not an instantiation
-func (T[* /* ERROR must be an identifier */ int]) m6() {} // syntax error
+func (T[* /* ERROR "must be an identifier" */ int]) m6() {} // syntax error
case map[T[int]] string:
case chan T[int]:
- case T /* ERROR cannot use generic type T\[P any\] without instantiation */ :
- case []T /* ERROR cannot use generic type */ :
- case [10]T /* ERROR cannot use generic type */ :
- case struct{T /* ERROR cannot use generic type */ }:
- case *T /* ERROR cannot use generic type */ :
- case func(T /* ERROR cannot use generic type */ ):
- case interface{m(T /* ERROR cannot use generic type */ )}:
- case map[T /* ERROR cannot use generic type */ ] string:
- case chan T /* ERROR cannot use generic type */ :
-
- case T /* ERROR cannot use generic type */ , *T /* ERROR cannot use generic type */ :
+ case T /* ERROR "cannot use generic type T\[P any\] without instantiation" */ :
+ case []T /* ERROR "cannot use generic type" */ :
+ case [10]T /* ERROR "cannot use generic type" */ :
+ case struct{T /* ERROR "cannot use generic type" */ }:
+ case *T /* ERROR "cannot use generic type" */ :
+ case func(T /* ERROR "cannot use generic type" */ ):
+ case interface{m(T /* ERROR "cannot use generic type" */ )}:
+ case map[T /* ERROR "cannot use generic type" */ ] string:
+ case chan T /* ERROR "cannot use generic type" */ :
+
+ case T /* ERROR "cannot use generic type" */ , *T /* ERROR "cannot use generic type" */ :
}
}
func _(x interface{}) {
var nil int
switch x.(type) {
- case nil /* ERROR not a type */ : // not ok - this is the variable nil
+ case nil /* ERROR "not a type" */ : // not ok - this is the variable nil
}
}
value A
}
-func Nest[A /* ERROR instantiation cycle */ any](b Box[A], n int) interface{} {
+func Nest[A /* ERROR "instantiation cycle" */ any](b Box[A], n int) interface{} {
if n == 0 {
return b
}
var _ = (T[int]).A
var _ = (*T[int]).A
-var _ = (T /* ERROR cannot use generic type */).A
-var _ = (*T /* ERROR cannot use generic type */).A
+var _ = (T /* ERROR "cannot use generic type" */).A
+var _ = (*T /* ERROR "cannot use generic type" */).A
package issue48082
-import "init" /* ERROR init must be a func */ /* ERROR could not import init */
+import "init" /* ERROR "init must be a func" */ /* ERROR "could not import init" */
type T[P any] struct{}
-type _ interface{ int | T /* ERROR cannot use generic type */ }
\ No newline at end of file
+type _ interface{ int | T /* ERROR "cannot use generic type" */ }
\ No newline at end of file
func f6[P interface { *Tree[P] }, Q any ]() {}
func _() {
- f1 /* ERROR cannot infer P */ ()
- f2 /* ERROR cannot infer P */ ()
- f3 /* ERROR cannot infer P */ ()
- f4 /* ERROR cannot infer P */ ()
- f5 /* ERROR cannot infer P */ ()
- f6 /* ERROR cannot infer P */ ()
+ f1 /* ERROR "cannot infer P" */ ()
+ f2 /* ERROR "cannot infer P" */ ()
+ f3 /* ERROR "cannot infer P" */ ()
+ f4 /* ERROR "cannot infer P" */ ()
+ f5 /* ERROR "cannot infer P" */ ()
+ f6 /* ERROR "cannot infer P" */ ()
}
type Tree[P any] struct {
}
func _() {
- foo /* ERROR cannot infer Src */ ()
+ foo /* ERROR "cannot infer Src" */ ()
}
type P *T
func _(p *T) {
- p.m /* ERROR type \*T is pointer to interface, not interface */ ()
+ p.m /* ERROR "type \*T is pointer to interface, not interface" */ ()
}
func _(p P) {
- p.m /* ERROR type P is pointer to interface, not interface */ ()
+ p.m /* ERROR "type P is pointer to interface, not interface" */ ()
}
func _[P T](p *P) {
- p.m /* ERROR type \*P is pointer to type parameter, not type parameter */ ()
+ p.m /* ERROR "type \*P is pointer to type parameter, not type parameter" */ ()
}
func g() {
var s string
var i int
- _ = s /* ERROR invalid operation: s \+ i \(mismatched types string and int\) */ + i
+ _ = s /* ERROR "invalid operation: s \+ i \(mismatched types string and int\)" */ + i
}
func f(i int) int {
- i /* ERROR invalid operation: i \+= "1" \(mismatched types int and untyped string\) */ += "1"
+ i /* ERROR "invalid operation: i \+= "1" \(mismatched types int and untyped string\)" */ += "1"
return i
}
package p
-type T /* ERROR invalid recursive type */ [U interface{ M() T[U, int] }] int
+type T /* ERROR "invalid recursive type" */ [U interface{ M() T[U, int] }] int
type X int
package p
-type N /* ERROR invalid recursive type */ interface {
+type N /* ERROR "invalid recursive type" */ interface {
int | N
}
-type A /* ERROR invalid recursive type */ interface {
+type A /* ERROR "invalid recursive type" */ interface {
int | B
}
int | A
}
-type S /* ERROR invalid recursive type */ struct {
- I // ERROR interface contains type constraints
+type S /* ERROR "invalid recursive type" */ struct {
+ I // ERROR "interface contains type constraints"
}
type I interface {
}
type P interface {
- *P // ERROR interface contains type constraints
+ *P // ERROR "interface contains type constraints"
}
func f[P any](a, _ P) {
var x int
// TODO(gri) these error messages, while correct, could be better
- f(a, x /* ERROR type int of x does not match inferred type P for P */)
- f(x, a /* ERROR type P of a does not match inferred type int for P */)
+ f(a, x /* ERROR "type int of x does not match inferred type P for P" */)
+ f(x, a /* ERROR "type P of a does not match inferred type int for P" */)
}
func g[P any](a, b P) {
_ = f[P]
}
-func f2[P /* ERROR instantiation cycle */ *Q, Q any](P, Q) {
+func f2[P /* ERROR "instantiation cycle" */ *Q, Q any](P, Q) {
_ = f2[*P]
}
// Other types of recursion through methods.
type R[P any] int
-func (*R[R /* ERROR must be an identifier */ [int]]) m0() {}
+func (*R[R /* ERROR "must be an identifier" */ [int]]) m0() {}
func (R[P]) m1(R[R[P]]) {}
func (R[P]) m2(R[*P]) {}
func (R[P]) m3([unsafe.Sizeof(new(R[P]))]int) {}
_ = y == x
_ = y == y
- _ = x /* ERROR type parameter P is not comparable with < */ < y
+ _ = x /* ERROR "type parameter P is not comparable with <" */ < y
}
func _[P comparable](x P, y any) {
_ = y == x
_ = y == y
- _ = x /* ERROR type parameter P is not comparable with < */ < y
+ _ = x /* ERROR "type parameter P is not comparable with <" */ < y
}
func _[P any](x, y P) {
- _ = x /* ERROR incomparable types in type set */ == x
- _ = x /* ERROR incomparable types in type set */ == y
- _ = y /* ERROR incomparable types in type set */ == x
- _ = y /* ERROR incomparable types in type set */ == y
+ _ = x /* ERROR "incomparable types in type set" */ == x
+ _ = x /* ERROR "incomparable types in type set" */ == y
+ _ = y /* ERROR "incomparable types in type set" */ == x
+ _ = y /* ERROR "incomparable types in type set" */ == y
- _ = x /* ERROR type parameter P is not comparable with < */ < y
+ _ = x /* ERROR "type parameter P is not comparable with <" */ < y
}
func _[P any](x P, y any) {
- _ = x /* ERROR incomparable types in type set */ == x
- _ = x /* ERROR incomparable types in type set */ == y
- _ = y == x // ERROR incomparable types in type set
+ _ = x /* ERROR "incomparable types in type set" */ == x
+ _ = x /* ERROR "incomparable types in type set" */ == y
+ _ = y == x // ERROR "incomparable types in type set"
_ = y == y
- _ = x /* ERROR type parameter P is not comparable with < */ < y
+ _ = x /* ERROR "type parameter P is not comparable with <" */ < y
}
import "unsafe"
-type T /* ERROR invalid recursive type: T refers to itself */ struct {
+type T /* ERROR "invalid recursive type: T refers to itself" */ struct {
T
}
package p
type (
- A1[P any] [10]A1 /* ERROR invalid recursive type */ [P]
- A2[P any] [10]A2 /* ERROR invalid recursive type */ [*P]
+ A1[P any] [10]A1 /* ERROR "invalid recursive type" */ [P]
+ A2[P any] [10]A2 /* ERROR "invalid recursive type" */ [*P]
A3[P any] [10]*A3[P]
L1[P any] []L1[P]
- S1[P any] struct{ f S1 /* ERROR invalid recursive type */ [P] }
- S2[P any] struct{ f S2 /* ERROR invalid recursive type */ [*P] } // like example in issue
+ S1[P any] struct{ f S1 /* ERROR "invalid recursive type" */ [P] }
+ S2[P any] struct{ f S2 /* ERROR "invalid recursive type" */ [*P] } // like example in issue
S3[P any] struct{ f *S3[P] }
- I1[P any] interface{ I1 /* ERROR invalid recursive type */ [P] }
- I2[P any] interface{ I2 /* ERROR invalid recursive type */ [*P] }
- I3[P any] interface{ *I3 /* ERROR interface contains type constraints */ [P] }
+ I1[P any] interface{ I1 /* ERROR "invalid recursive type" */ [P] }
+ I2[P any] interface{ I2 /* ERROR "invalid recursive type" */ [*P] }
+ I3[P any] interface{ *I3 /* ERROR "interface contains type constraints" */ [P] }
)
f P
}
-type T1 /* ERROR invalid recursive type */ struct {
+type T1 /* ERROR "invalid recursive type" */ struct {
_ T0[T1]
}
Foo()
}
-type Fooable[F /* ERROR instantiation cycle */ Fooer] struct {
+type Fooable[F /* ERROR "instantiation cycle" */ Fooer] struct {
ptr F
}
func f(s string) int {
for range s {
}
-} // ERROR missing return
+} // ERROR "missing return"
func F1() T1
-var _ = F1().(*X1 /* ERROR undefined: X1 */)
+var _ = F1().(*X1 /* ERROR "undefined: X1" */)
func _() {
switch F1().(type) {
- case *X1 /* ERROR undefined: X1 */ :
+ case *X1 /* ERROR "undefined: X1" */ :
}
}
func F2() T2
-var _ = F2 /* ERROR impossible type assertion: F2\(\)\.\(\*X2\)\n\t\*X2 does not implement T2 \(missing method M\) */ ().(*X2)
+var _ = F2 /* ERROR "impossible type assertion: F2\(\)\.\(\*X2\)\n\t\*X2 does not implement T2 \(missing method M\)" */ ().(*X2)
type X2 struct{}
func _() {
switch F2().(type) {
- case * /* ERROR impossible type switch case: \*X2\n\tF2\(\) \(value of type T2\) cannot have dynamic type \*X2 \(missing method M\) */ X2:
+ case * /* ERROR "impossible type switch case: \*X2\n\tF2\(\) \(value of type T2\) cannot have dynamic type \*X2 \(missing method M\)" */ X2:
}
}
// The example from the issue.
type (
- N[P any] M /* ERROR invalid recursive type */ [P]
+ N[P any] M /* ERROR "invalid recursive type" */ [P]
M[P any] N[P]
)
// A slightly more complicated case.
type (
- A[P any] B /* ERROR invalid recursive type */ [P]
+ A[P any] B /* ERROR "invalid recursive type" */ [P]
B[P any] C[P]
C[P any] A[P]
)
func _() {
_ = f[int]
- _ = f[[ /* ERROR \[\]int does not satisfy int */ ]int]
+ _ = f[[ /* ERROR "\[\]int does not satisfy int" */ ]int]
f(0)
- f/* ERROR \[\]int does not satisfy int */ ([]int{})
+ f/* ERROR "\[\]int does not satisfy int" */ ([]int{})
}
func _() {
_ = f1[int]
- _ = f1[myInt /* ERROR possibly missing ~ for int in int \| string */]
+ _ = f1[myInt /* ERROR "possibly missing ~ for int in int \| string" */]
_ = f2[myInt]
- _ = f2[myFloat /* ERROR possibly missing ~ for float64 in ~int \| string \| float64 */]
+ _ = f2[myFloat /* ERROR "possibly missing ~ for float64 in ~int \| string \| float64" */]
var x myInt
- f3 /* ERROR myInt does not satisfy int \(possibly missing ~ for int in int\) */ (x)
+ f3 /* ERROR "myInt does not satisfy int \(possibly missing ~ for int in int\)" */ (x)
}
// test case from the issue
type MySlice []int
func f(s MySlice) {
- Map[MySlice /* ERROR MySlice does not satisfy SliceConstraint\[int\] \(possibly missing ~ for \[\]int in SliceConstraint\[int\]\) */, int](s, nil)
+ Map[MySlice /* ERROR "MySlice does not satisfy SliceConstraint\[int\] \(possibly missing ~ for \[\]int in SliceConstraint\[int\]\)" */, int](s, nil)
}
package p
func _[P int](x P) int {
- return x // ERROR cannot use x .* as int value in return statement
+ return x // ERROR "cannot use x .* as int value in return statement"
}
func _[P int]() int {
- return P /* ERROR cannot use P\(1\) .* as int value in return statement */ (1)
+ return P /* ERROR "cannot use P\(1\) .* as int value in return statement" */ (1)
}
func _[P int](x int) P {
- return x // ERROR cannot use x .* as P value in return statement
+ return x // ERROR "cannot use x .* as P value in return statement"
}
func _[P, Q any](x P) Q {
- return x // ERROR cannot use x .* as Q value in return statement
+ return x // ERROR "cannot use x .* as Q value in return statement"
}
// test case from issue
func F[G interface{ uint }]() int {
f := func(uint) int { return 0 }
- return f(G /* ERROR cannot use G\(1\) .* as uint value in argument to f */ (1))
+ return f(G /* ERROR "cannot use G\(1\) .* as uint value in argument to f" */ (1))
}
func Add1024[T integer](s []T) {
for i, v := range s {
- s[i] = v + 1024 // ERROR cannot convert 1024 \(untyped int constant\) to type T
+ s[i] = v + 1024 // ERROR "cannot convert 1024 \(untyped int constant\) to type T"
}
}
func f[T interface{ int8 }]() {
- println(T(1024 /* ERROR cannot convert 1024 \(untyped int value\) to type T */))
+ println(T(1024 /* ERROR "cannot convert 1024 \(untyped int value\) to type T" */))
}
import "unsafe"
-type S /* ERROR invalid recursive type S */ struct {
+type S /* ERROR "invalid recursive type S" */ struct {
_ [unsafe.Sizeof(s)]byte
}
// Since f is a pointer, this case could be valid.
// But it's pathological and not worth the expense.
type T struct {
- f *[unsafe.Sizeof(T /* ERROR invalid recursive type */ {})]int
+ f *[unsafe.Sizeof(T /* ERROR "invalid recursive type" */ {})]int
}
// a mutually recursive case using unsafe.Sizeof
}
B1 struct {
- _ [unsafe.Sizeof(A1 /* ERROR invalid recursive type */ {})]int
+ _ [unsafe.Sizeof(A1 /* ERROR "invalid recursive type" */ {})]int
}
)
}
B2 struct {
- f [len(A2 /* ERROR invalid recursive type */ {}.f)]int
+ f [len(A2 /* ERROR "invalid recursive type" */ {}.f)]int
}
)
// test case from issue
type a struct {
- _ [42 - unsafe.Sizeof(a /* ERROR invalid recursive type */ {})]byte
+ _ [42 - unsafe.Sizeof(a /* ERROR "invalid recursive type" */ {})]byte
}
T1 []int,
T2 ~float64 | ~complex128 | chan int,
]() {
- _ = T0(nil /* ERROR cannot convert nil to type T0 */ )
- _ = T1(1 /* ERROR cannot convert 1 .* to type T1 */ )
- _ = T2(2 /* ERROR cannot convert 2 .* to type T2 */ )
+ _ = T0(nil /* ERROR "cannot convert nil to type T0" */ )
+ _ = T1(1 /* ERROR "cannot convert 1 .* to type T1" */ )
+ _ = T2(2 /* ERROR "cannot convert 2 .* to type T2" */ )
}
// test case from issue
func f[T interface{[]int}]() {
- _ = T(1 /* ERROR cannot convert */ )
+ _ = T(1 /* ERROR "cannot convert" */ )
}
import "unsafe"
-type T0 /* ERROR invalid recursive type */ [P T0[P]] struct{}
+type T0 /* ERROR "invalid recursive type" */ [P T0[P]] struct{}
-type T1 /* ERROR invalid recursive type */ [P T2[P]] struct{}
+type T1 /* ERROR "invalid recursive type" */ [P T2[P]] struct{}
type T2[P T1[P]] struct{}
-type T3 /* ERROR invalid recursive type */ [P interface{ ~struct{ f T3[int] } }] struct{}
+type T3 /* ERROR "invalid recursive type" */ [P interface{ ~struct{ f T3[int] } }] struct{}
// valid cycle in M
type N[P M[P]] struct{}
})]byte] struct{}
// test case from issue
-type X /* ERROR invalid recursive type */ [T any, PT X[T]] interface{}
+type X /* ERROR "invalid recursive type" */ [T any, PT X[T]] interface{}
// The following parse as invalid array types due to parsing ambiguitiues.
type _ [P *int /* ERROR "int \(type\) is not an expression" */ ]int
-type _ [P /* ERROR non-function P */ (*int)]int
+type _ [P /* ERROR "non-function P" */ (*int)]int
// Adding a trailing comma or an enclosing interface resolves the ambiguity.
type _[P *int,] int
// TODO(gri): with type-type inference enabled we should only report one error
// below. See issue #50588.
-func _[A any](s S /* ERROR got 1 arguments but 2 type parameters */ [A]) {
+func _[A any](s S /* ERROR "got 1 arguments but 2 type parameters" */ [A]) {
// we should see no follow-on errors below
s.f = 1
s.m()
// another test case from the issue
func _() {
- X(Interface[*F /* ERROR got 1 arguments but 2 type parameters */ [string]](Impl{}))
+ X(Interface[*F /* ERROR "got 1 arguments but 2 type parameters" */ [string]](Impl{}))
}
func X[Q Qer](fs Interface[Q]) {
}
func G[F any]() I[any] {
- return g /* ERROR cannot use g\[F\]{} .* as I\[any\] value in return statement: g\[F\] does not implement I\[any\] \(method Q has pointer receiver\) */ [F]{}
+ return g /* ERROR "cannot use g\[F\]{} .* as I\[any\] value in return statement: g\[F\] does not implement I\[any\] \(method Q has pointer receiver\)" */ [F]{}
}
type g[F any] struct{}
}
type _ interface {
- int | M // ERROR cannot use p\.M in union \(p\.M contains methods\)
- int | comparable // ERROR cannot use comparable in union
- int | C // ERROR cannot use p\.C in union \(p\.C embeds comparable\)
+ int | M // ERROR "cannot use p\.M in union \(p\.M contains methods\)"
+ int | comparable // ERROR "cannot use comparable in union"
+ int | C // ERROR "cannot use p\.C in union \(p\.C embeds comparable\)"
}
package p
func _[P1 any, P2 ~byte](s1 P1, s2 P2) {
- _ = append(nil /* ERROR first argument to append must be a slice; have untyped nil */ , 0)
- _ = append(s1 /* ERROR s1 .* has no core type */ , 0)
- _ = append(s2 /* ERROR s2 .* has core type byte */ , 0)
+ _ = append(nil /* ERROR "first argument to append must be a slice; have untyped nil" */ , 0)
+ _ = append(s1 /* ERROR "s1 .* has no core type" */ , 0)
+ _ = append(s2 /* ERROR "s2 .* has core type byte" */ , 0)
}
type A int
type C interface {
- ~ /* ERROR invalid use of ~ */ A
+ ~ /* ERROR "invalid use of ~" */ A
}
func f[_ C]() {}
func h[_ C | int]() {}
func _() {
- _ = f[int /* ERROR cannot satisfy C \(empty type set\) */]
- _ = g[int /* ERROR cannot satisfy interface{C} \(empty type set\) */]
+ _ = f[int /* ERROR "cannot satisfy C \(empty type set\)" */]
+ _ = g[int /* ERROR "cannot satisfy interface{C} \(empty type set\)" */]
_ = h[int]
}
package p
func _[P ~int, Q any](p P) {
- _ = Q(p /* ERROR cannot convert */ )
+ _ = Q(p /* ERROR "cannot convert" */ )
}
package p
-func Ln[A A /* ERROR cannot use a type parameter as constraint */ ](p A) {
+func Ln[A A /* ERROR "cannot use a type parameter as constraint" */ ](p A) {
}
for range s {}
for i = range s {}
for i, j = range s {}
- for i, j, k /* ERROR range clause permits at most two iteration variables|at most 2 expressions */ = range s {}
- for i, j, k, l /* ERROR range clause permits at most two iteration variables|at most 2 expressions */ = range s {}
+ for i, j, k /* ERROR "range clause permits at most two iteration variables|at most 2 expressions" */ = range s {}
+ for i, j, k, l /* ERROR "range clause permits at most two iteration variables|at most 2 expressions" */ = range s {}
}
func _(s chan int) {
for range s {}
for i = range s {}
- for i, j /* ERROR range over .* permits only one iteration variable */ = range s {}
- for i, j, k /* ERROR range over .* permits only one iteration variable|at most 2 expressions */ = range s {}
- for i, j, k, l /* ERROR range over .* permits only one iteration variable|at most 2 expressions */ = range s {}
+ for i, j /* ERROR "range over .* permits only one iteration variable" */ = range s {}
+ for i, j, k /* ERROR "range over .* permits only one iteration variable|at most 2 expressions" */ = range s {}
+ for i, j, k, l /* ERROR "range over .* permits only one iteration variable|at most 2 expressions" */ = range s {}
}
}
func f0[P Sf](p P) {
- _ = p.f // ERROR p\.f undefined
- p.f /* ERROR p\.f undefined */ = 0
+ _ = p.f // ERROR "p\.f undefined"
+ p.f /* ERROR "p\.f undefined" */ = 0
}
func f0t[P ~struct{f int}](p P) {
- _ = p.f // ERROR p\.f undefined
- p.f /* ERROR p\.f undefined */ = 0
+ _ = p.f // ERROR "p\.f undefined"
+ p.f /* ERROR "p\.f undefined" */ = 0
}
var _ = f0[Sf]
var _ = f0t[Sf]
-var _ = f0[Sm /* ERROR does not satisfy */ ]
-var _ = f0t[Sm /* ERROR does not satisfy */ ]
+var _ = f0[Sm /* ERROR "does not satisfy" */ ]
+var _ = f0t[Sm /* ERROR "does not satisfy" */ ]
func f1[P interface{ Sf; m() }](p P) {
- _ = p.f // ERROR p\.f undefined
- p.f /* ERROR p\.f undefined */ = 0
+ _ = p.f // ERROR "p\.f undefined"
+ p.f /* ERROR "p\.f undefined" */ = 0
p.m()
}
-var _ = f1[Sf /* ERROR missing method m */ ]
-var _ = f1[Sm /* ERROR does not satisfy */ ]
+var _ = f1[Sf /* ERROR "missing method m" */ ]
+var _ = f1[Sm /* ERROR "does not satisfy" */ ]
type Sm struct {}
func (Sfm) m() {}
func f2[P interface{ Sfm; m() }](p P) {
- _ = p.f // ERROR p\.f undefined
- p.f /* ERROR p\.f undefined */ = 0
+ _ = p.f // ERROR "p\.f undefined"
+ p.f /* ERROR "p\.f undefined" */ = 0
p.m()
}
type PSfm *Sfm
func f3[P interface{ PSfm }](p P) {
- _ = p.f // ERROR p\.f undefined
- p.f /* ERROR p\.f undefined */ = 0
- p.m /* ERROR type P has no field or method m */ ()
+ _ = p.f // ERROR "p\.f undefined"
+ p.f /* ERROR "p\.f undefined" */ = 0
+ p.m /* ERROR "type P has no field or method m" */ ()
}
var _ = f3[PSfm]
package p
func _[P struct{ f int }](x P) {
- _ = x.g // ERROR type P has no field or method g
+ _ = x.g // ERROR "type P has no field or method g"
}
func _[P struct{ f int } | struct{ g int }](x P) {
- _ = x.g // ERROR type P has no field or method g
+ _ = x.g // ERROR "type P has no field or method g"
}
func _[P comparable, Q ~int, R any]() {
_ = f1[int]
- _ = f1[T /* ERROR T does not satisfy comparable */ ]
- _ = f1[any /* ERROR any does not satisfy comparable */ ]
+ _ = f1[T /* ERROR "T does not satisfy comparable" */ ]
+ _ = f1[any /* ERROR "any does not satisfy comparable" */ ]
_ = f1[P]
_ = f1[Q]
- _ = f1[R /* ERROR R does not satisfy comparable */]
+ _ = f1[R /* ERROR "R does not satisfy comparable" */]
_ = f2[int]
- _ = f2[T /* ERROR T does not satisfy comparable */ ]
- _ = f2[any /* ERROR any does not satisfy comparable */ ]
+ _ = f2[T /* ERROR "T does not satisfy comparable" */ ]
+ _ = f2[any /* ERROR "any does not satisfy comparable" */ ]
_ = f2[P]
_ = f2[Q]
- _ = f2[R /* ERROR R does not satisfy comparable */]
+ _ = f2[R /* ERROR "R does not satisfy comparable" */]
}
type SR = R[SS, ST]
type SS interface {
- NSR(any) *SR // ERROR invalid use of type alias SR in recursive type
+ NSR(any) *SR // ERROR "invalid use of type alias SR in recursive type"
}
type C interface {
// AbsDifference computes the absolute value of the difference of
// a and b, where the absolute value is determined by the Abs method.
-func absDifference[T numericAbs[T /* ERROR T does not satisfy Numeric */]](a, b T) T {
+func absDifference[T numericAbs[T /* ERROR "T does not satisfy Numeric" */]](a, b T) T {
// Field accesses are not permitted for now. Keep an error so
// we can find and fix this code once the situation changes.
- return a.Value // ERROR a\.Value undefined
+ return a.Value // ERROR "a\.Value undefined"
// TODO: The error below should probably be positioned on the '-'.
// d := a /* ERROR "invalid operation: operator - not defined" */ .Value - b.Value
// return d.Abs()
func _() {
var i I
- _ = i /* ERROR impossible type assertion: i\.\(T1\)\n\tT1 does not implement I \(missing method Foo\)\n\t\thave foo\(\)\n\t\twant Foo\(\) */ .(T1)
- _ = i /* ERROR impossible type assertion: i\.\(T2\)\n\tT2 does not implement I \(missing method Foo\)\n\t\thave foo\(\) string\n\t\twant Foo\(\) */ .(T2)
+ _ = i /* ERROR "impossible type assertion: i\.\(T1\)\n\tT1 does not implement I \(missing method Foo\)\n\t\thave foo\(\)\n\t\twant Foo\(\)" */ .(T1)
+ _ = i /* ERROR "impossible type assertion: i\.\(T2\)\n\tT2 does not implement I \(missing method Foo\)\n\t\thave foo\(\) string\n\t\twant Foo\(\)" */ .(T2)
}
package p
func Real[P ~complex128](x P) {
- _ = real(x /* ERROR not supported */ )
+ _ = real(x /* ERROR "not supported" */ )
}
func Imag[P ~complex128](x P) {
- _ = imag(x /* ERROR not supported */ )
+ _ = imag(x /* ERROR "not supported" */ )
}
func Complex[P ~float64](x P) {
- _ = complex(x /* ERROR not supported */ , 0)
- _ = complex(0 /* ERROR not supported */ , x)
- _ = complex(x /* ERROR not supported */ , x)
+ _ = complex(x /* ERROR "not supported" */ , 0)
+ _ = complex(0 /* ERROR "not supported" */ , x)
+ _ = complex(x /* ERROR "not supported" */ , x)
}
func _() {
var a1, b1 thing1
- _ = a1 /* ERROR struct containing \[\]string cannot be compared */ == b1
+ _ = a1 /* ERROR "struct containing \[\]string cannot be compared" */ == b1
var a2, b2 thing2
- _ = a2 /* ERROR struct containing \[\]thing1 cannot be compared */ == b2
+ _ = a2 /* ERROR "struct containing \[\]thing1 cannot be compared" */ == b2
}
func _() {
// TODO(gri) only report one error below (issue #50932)
- var x F /* ERROR got 1 arguments but 2 type parameters */ [int]
- G(x /* ERROR does not match */)
+ var x F /* ERROR "got 1 arguments but 2 type parameters" */ [int]
+ G(x /* ERROR "does not match" */)
}
// test case from issue
fmt.Println(c)
}
-func MMD[Rc RC /* ERROR got 1 arguments */ [RG], RG any, G any]() M /* ERROR got 2 arguments */ [Rc, RG] {
+func MMD[Rc RC /* ERROR "got 1 arguments" */ [RG], RG any, G any]() M /* ERROR "got 2 arguments" */ [Rc, RG] {
- var nFn NFn /* ERROR got 2 arguments */ [Rc, RG]
+ var nFn NFn /* ERROR "got 2 arguments" */ [Rc, RG]
var empty Rc
switch any(empty).(type) {
- case BC /* ERROR undefined: BC */ :
+ case BC /* ERROR "undefined: BC" */ :
case RSC[G]:
- nFn = NSG /* ERROR cannot use NSG\[G\] */ [G]
+ nFn = NSG /* ERROR "cannot use NSG\[G\]" */ [G]
}
- return M /* ERROR got 2 arguments */ [Rc, RG]{
+ return M /* ERROR "got 2 arguments" */ [Rc, RG]{
Fn: func(rc Rc) {
- NC(nFn /* ERROR does not match */ )
+ NC(nFn /* ERROR "does not match" */ )
},
}
- return M /* ERROR got 2 arguments */ [Rc, RG]{}
+ return M /* ERROR "got 2 arguments" */ [Rc, RG]{}
}
func _(x int, c string) {
switch x {
- case c /* ERROR invalid case c in switch on x \(mismatched types string and int\) */ :
+ case c /* ERROR "invalid case c in switch on x \(mismatched types string and int\)" */ :
}
}
func _(x, c []int) {
switch x {
- case c /* ERROR invalid case c in switch on x \(slice can only be compared to nil\) */ :
+ case c /* ERROR "invalid case c in switch on x \(slice can only be compared to nil\)" */ :
}
}
package p
-var _ interface{ m() } = struct /* ERROR m is a field, not a method */ {
+var _ interface{ m() } = struct /* ERROR "m is a field, not a method" */ {
m func()
}{}
-var _ interface{ m() } = & /* ERROR m is a field, not a method */ struct {
+var _ interface{ m() } = & /* ERROR "m is a field, not a method" */ struct {
m func()
}{}
-var _ interface{ M() } = struct /* ERROR missing method M */ {
+var _ interface{ M() } = struct /* ERROR "missing method M" */ {
m func()
}{}
-var _ interface{ M() } = & /* ERROR missing method M */ struct {
+var _ interface{ M() } = & /* ERROR "missing method M" */ struct {
m func()
}{}
var i I
i = m
- i = t // ERROR m is a field, not a method
+ i = t // ERROR "m is a field, not a method"
_ = i
}
import "fmt"
type (
- _ [fmt /* ERROR invalid array length fmt */ ]int
- _ [float64 /* ERROR invalid array length float64 */ ]int
- _ [f /* ERROR invalid array length f */ ]int
- _ [nil /* ERROR invalid array length nil */ ]int
+ _ [fmt /* ERROR "invalid array length fmt" */ ]int
+ _ [float64 /* ERROR "invalid array length float64" */ ]int
+ _ [f /* ERROR "invalid array length f" */ ]int
+ _ [nil /* ERROR "invalid array length nil" */ ]int
)
func f()
func _() {
// P can be inferred as there's a single specific type and no tilde.
- var _ chan int = ch1 /* ERROR cannot use ch1.*value of type chan<- int */ ()
+ var _ chan int = ch1 /* ERROR "cannot use ch1.*value of type chan<- int" */ ()
var _ chan<- int = ch1()
// P cannot be inferred as there's a tilde.
- ch2 /* ERROR cannot infer P */ ()
+ ch2 /* ERROR "cannot infer P" */ ()
type myChan chan int
ch2[myChan]()
ch3(e)
// P cannot be inferred as there's more than one specific type and a tilde.
- ch4 /* ERROR cannot infer P */ (e)
+ ch4 /* ERROR "cannot infer P" */ (e)
_ = ch4[chan int]
// P cannot be inferred as there's more than one specific type.
- ch5 /* ERROR cannot infer P */ ()
+ ch5 /* ERROR "cannot infer P" */ ()
ch5[chan<- int]()
}
type Fn[RCT RC[RG], RG any] func(RCT)
type F[RCT RC[RG], RG any] interface {
- Fn() Fn /* ERROR got 1 arguments */ [RCT]
+ Fn() Fn /* ERROR "got 1 arguments" */ [RCT]
}
type concreteF[RCT RC[RG], RG any] struct {
- makeFn func() Fn /* ERROR got 1 arguments */ [RCT]
+ makeFn func() Fn /* ERROR "got 1 arguments" */ [RCT]
}
-func (c *concreteF[RCT, RG]) Fn() Fn /* ERROR got 1 arguments */ [RCT] {
+func (c *concreteF[RCT, RG]) Fn() Fn /* ERROR "got 1 arguments" */ [RCT] {
return c.makeFn()
}
-func NewConcrete[RCT RC[RG], RG any](Rc RCT) F /* ERROR got 1 arguments */ [RCT] {
+func NewConcrete[RCT RC[RG], RG any](Rc RCT) F /* ERROR "got 1 arguments" */ [RCT] {
// TODO(rfindley): eliminate the duplicate error below.
- return & /* ERROR cannot use .* as F\[RCT\] */ concreteF /* ERROR got 1 arguments */ [RCT]{
+ return & /* ERROR "cannot use .* as F\[RCT\]" */ concreteF /* ERROR "got 1 arguments" */ [RCT]{
makeFn: nil,
}
}
type Fn[RCT RC[RG], RG any] func(RCT)
-type FFn[RCT RC[RG], RG any] func() Fn /* ERROR got 1 arguments */ [RCT]
+type FFn[RCT RC[RG], RG any] func() Fn /* ERROR "got 1 arguments" */ [RCT]
type F[RCT RC[RG], RG any] interface {
- Fn() Fn /* ERROR got 1 arguments */ [RCT]
+ Fn() Fn /* ERROR "got 1 arguments" */ [RCT]
}
type concreteF[RCT RC[RG], RG any] struct {
- makeFn FFn /* ERROR got 1 arguments */ [RCT]
+ makeFn FFn /* ERROR "got 1 arguments" */ [RCT]
}
-func (c *concreteF[RCT, RG]) Fn() Fn /* ERROR got 1 arguments */ [RCT] {
+func (c *concreteF[RCT, RG]) Fn() Fn /* ERROR "got 1 arguments" */ [RCT] {
return c.makeFn()
}
func _[P1 comparable, P2 S2]() {
_ = f[S1]
- _ = f[S2 /* ERROR S2 does not satisfy comparable */ ]
- _ = f[S3 /* ERROR S3 does not satisfy comparable */ ]
+ _ = f[S2 /* ERROR "S2 does not satisfy comparable" */ ]
+ _ = f[S3 /* ERROR "S3 does not satisfy comparable" */ ]
type L1 struct { x P1 }
type L2 struct { x P2 }
_ = f[L1]
- _ = f[L2 /* ERROR L2 does not satisfy comparable */ ]
+ _ = f[L2 /* ERROR "L2 does not satisfy comparable" */ ]
}
type T struct{ x any }
func main() {
- NewSetFromSlice /* ERROR T does not satisfy comparable */ ([]T{
+ NewSetFromSlice /* ERROR "T does not satisfy comparable" */ ([]T{
{"foo"},
{5},
})
type S2 struct{}
func _[P *S1|*S2]() {
- _= []P{{ /* ERROR invalid composite literal element type P \(no core type\) */ }}
+ _= []P{{ /* ERROR "invalid composite literal element type P \(no core type\)" */ }}
}
func _[P *S1|S1]() {
- _= []P{{ /* ERROR invalid composite literal element type P \(no core type\) */ }}
+ _= []P{{ /* ERROR "invalid composite literal element type P \(no core type\)" */ }}
}
type T[P any, B *P] struct{}
-func (T /* ERROR cannot use generic type */ ) m0() {}
+func (T /* ERROR "cannot use generic type" */ ) m0() {}
// TODO(rfindley): eliminate the duplicate errors here.
-func (/* ERROR got 1 type parameter, but receiver base type declares 2 */ T /* ERROR got 1 arguments but 2 type parameters */ [_]) m1() {}
+func (/* ERROR "got 1 type parameter, but receiver base type declares 2" */ T /* ERROR "got 1 arguments but 2 type parameters" */ [_]) m1() {}
func (T[_, _]) m2() {}
// TODO(gri) this error is unfortunate (issue #51343)
-func (T /* ERROR got 3 arguments but 2 type parameters */ [_, _, _]) m3() {}
+func (T /* ERROR "got 3 arguments but 2 type parameters" */ [_, _, _]) m3() {}
package p
func _() {
- len.Println /* ERROR cannot select on len */
- len.Println /* ERROR cannot select on len */ ()
- _ = len.Println /* ERROR cannot select on len */
- _ = len /* ERROR cannot index len */ [0]
- _ = *len /* ERROR cannot indirect len */
+ len.Println /* ERROR "cannot select on len" */
+ len.Println /* ERROR "cannot select on len" */ ()
+ _ = len.Println /* ERROR "cannot select on len" */
+ _ = len /* ERROR "cannot index len" */ [0]
+ _ = *len /* ERROR "cannot indirect len" */
}
func _[M1 ~map[K]V, M2 map[K]V, K comparable, V any]() {
var m1 M1
f(m1)
- g /* ERROR M1 does not satisfy map\[K\]V */ (m1) // M1 has tilde
+ g /* ERROR "M1 does not satisfy map\[K\]V" */ (m1) // M1 has tilde
var m2 M2
f(m2)
var m3 Map
f(m3)
- g /* ERROR Map does not satisfy map\[string\]int */ (m3) // M in g does not have tilde
+ g /* ERROR "Map does not satisfy map\[string\]int" */ (m3) // M in g does not have tilde
}
}
func _[T interface{comparable; ~[]byte}](x T) {
- _ = x /* ERROR empty type set */ == x
+ _ = x /* ERROR "empty type set" */ == x
}
// TODO(gri) The error message here should be better. See issue #51525.
func _[T interface{comparable; ~int; ~string}](x T) {
- _ = x /* ERROR empty type set */ == x
+ _ = x /* ERROR "empty type set" */ == x
}
// TODO(gri) The error message here should be better. See issue #51525.
func _[T interface{~int; ~string}](x T) {
- _ = x /* ERROR empty type set */ == x
+ _ = x /* ERROR "empty type set" */ == x
}
func _[T interface{comparable; interface{~int}; interface{int|float64}}](x T) {
}
func _[T interface{interface{comparable; ~int}; interface{~float64; comparable; m()}}](x T) {
- _ = x /* ERROR empty type set */ == x
+ _ = x /* ERROR "empty type set" */ == x
}
// test case from issue
}
func _(s []byte) {
- f /* ERROR \[\]byte does not satisfy interface{comparable; \[\]byte \| string} */ (s)
- _ = f[[ /* ERROR does not satisfy */ ]byte]
+ f /* ERROR "\[\]byte does not satisfy interface{comparable; \[\]byte \| string}" */ (s)
+ _ = f[[ /* ERROR "does not satisfy" */ ]byte]
}
package p
-type T /* ERROR invalid recursive type */ T.x
+type T /* ERROR "invalid recursive type" */ T.x
int
string
}](x T) {
- _ = x /* ERROR empty type set */ == x
- _ = x /* ERROR empty type set */ + x
- <-x /* ERROR empty type set */
- x <- /* ERROR empty type set */ 0
- close(x /* ERROR empty type set */)
+ _ = x /* ERROR "empty type set" */ == x
+ _ = x /* ERROR "empty type set" */ + x
+ <-x /* ERROR "empty type set" */
+ x <- /* ERROR "empty type set" */ 0
+ close(x /* ERROR "empty type set" */)
}
func _[T interface{ int | []byte }](x T) {
- _ = x /* ERROR incomparable types in type set */ == x
+ _ = x /* ERROR "incomparable types in type set" */ == x
}
func _(x any) {
switch x {
case 0:
- fallthrough // ERROR fallthrough statement out of place
+ fallthrough // ERROR "fallthrough statement out of place"
_ = x
default:
}
switch x.(type) {
case int:
- fallthrough // ERROR cannot fallthrough in type switch
+ fallthrough // ERROR "cannot fallthrough in type switch"
default:
}
}
package p
-var _ = (*interface /* ERROR interface contains type constraints */ {int})(nil)
+var _ = (*interface /* ERROR "interface contains type constraints" */ {int})(nil)
// abbreviated test case from issue
type TypeSet interface{ int | string }
func _() {
- f((*TypeSet /* ERROR interface contains type constraints */)(nil))
+ f((*TypeSet /* ERROR "interface contains type constraints" */)(nil))
}
func f(any) {}
\ No newline at end of file
type T = interface { m(int) }
func _() {
- _ = f /* ERROR cannot infer R */ [T] // don't crash in type inference
+ _ = f /* ERROR "cannot infer R" */ [T] // don't crash in type inference
}
type (
// overlap errors for non-interface terms
// (like the interface terms, but explicitly inlined)
- _ interface{int | int /* ERROR overlapping terms int and int */ }
- _ interface{int | ~ /* ERROR overlapping terms ~int and int */ int}
- _ interface{~int | int /* ERROR overlapping terms int and ~int */ }
- _ interface{~int | ~ /* ERROR overlapping terms ~int and ~int */ int}
+ _ interface{int | int /* ERROR "overlapping terms int and int" */ }
+ _ interface{int | ~ /* ERROR "overlapping terms ~int and int" */ int}
+ _ interface{~int | int /* ERROR "overlapping terms int and ~int" */ }
+ _ interface{~int | ~ /* ERROR "overlapping terms ~int and ~int" */ int}
- _ interface{T1 | bool | string | T1 | bool /* ERROR overlapping terms bool and bool */ | string /* ERROR overlapping terms string and string */ }
- _ interface{T1 | bool | string | T2 | ~ /* ERROR overlapping terms ~bool and bool */ bool | ~ /* ERROR overlapping terms ~string and string */ string}
+ _ interface{T1 | bool | string | T1 | bool /* ERROR "overlapping terms bool and bool" */ | string /* ERROR "overlapping terms string and string" */ }
+ _ interface{T1 | bool | string | T2 | ~ /* ERROR "overlapping terms ~bool and bool" */ bool | ~ /* ERROR "overlapping terms ~string and string" */ string}
// no errors for interface terms
_ interface{T1 | T1}
_ interface{T4 | T4 | float64 }
)
-func _[_ T1 | bool | string | T1 | bool /* ERROR overlapping terms */ ]() {}
-func _[_ T1 | bool | string | T2 | ~ /* ERROR overlapping terms */ bool ]() {}
-func _[_ T2 | ~bool | ~string | T1 | bool /* ERROR overlapping terms */ ]() {}
-func _[_ T2 | ~bool | ~string | T2 | ~ /* ERROR overlapping terms */ bool ]() {}
+func _[_ T1 | bool | string | T1 | bool /* ERROR "overlapping terms" */ ]() {}
+func _[_ T1 | bool | string | T2 | ~ /* ERROR "overlapping terms" */ bool ]() {}
+func _[_ T2 | ~bool | ~string | T1 | bool /* ERROR "overlapping terms" */ ]() {}
+func _[_ T2 | ~bool | ~string | T2 | ~ /* ERROR "overlapping terms" */ bool ]() {}
func _[_ T3 | T3 | int]() {}
func _[_ T3 | T4 | bool]() {}
package p
func _[P int | float64 | complex128]() {
- _ = map[P]int{1: 1, 1.0 /* ERROR duplicate key 1 */ : 2, 1 /* ERROR duplicate key \(1 \+ 0i\) */ + 0i: 3}
+ _ = map[P]int{1: 1, 1.0 /* ERROR "duplicate key 1" */ : 2, 1 /* ERROR "duplicate key \(1 \+ 0i\)" */ + 0i: 3}
}
package p
-type F { // ERROR expected type|type declaration
+type F { // ERROR "expected type|type declaration"
float64
-} // ERROR expected declaration|non-declaration statement
+} // ERROR "expected declaration|non-declaration statement"
func _[T F | int](x T) {
_ = x == 0 // don't crash when recording type of 0
// test case from issue
-type FloatType { // ERROR expected type|type declaration
+type FloatType { // ERROR "expected type|type declaration"
float32 | float64
-} // ERROR expected declaration|non-declaration statement
+} // ERROR "expected declaration|non-declaration statement"
type IntegerType interface {
int8 | int16 | int32 | int64 | int |
}
var (
- _ = S{0} /* ERROR too few values in struct literal */
- _ = struct{ f1, f2 int }{0} /* ERROR too few values in struct literal */
+ _ = S{0} /* ERROR "too few values in struct literal" */
+ _ = struct{ f1, f2 int }{0} /* ERROR "too few values in struct literal" */
- _ = S{0, true, "foo" /* ERROR too many values in struct literal */}
- _ = struct{ f1, f2 int }{0, 1, 2 /* ERROR too many values in struct literal */}
+ _ = S{0, true, "foo" /* ERROR "too many values in struct literal" */}
+ _ = struct{ f1, f2 int }{0, 1, 2 /* ERROR "too many values in struct literal" */}
)
func _() {
const x = 0
- x /* ERROR cannot assign to x */ += 1
- x /* ERROR cannot assign to x */ ++
+ x /* ERROR "cannot assign to x" */ += 1
+ x /* ERROR "cannot assign to x" */ ++
}
_ P
}
-type S /* ERROR invalid recursive type */ struct {
+type S /* ERROR "invalid recursive type" */ struct {
_ T[S]
}
import "unsafe"
type T[P any] struct {
- T /* ERROR invalid recursive type */ [P]
+ T /* ERROR "invalid recursive type" */ [P]
}
func _[P any]() {
// TODO(gri) This is a follow-on error due to T[int] being invalid.
// We should try to avoid it.
-const _ = unsafe /* ERROR not constant */ .Sizeof(T[int]{})
+const _ = unsafe /* ERROR "not constant" */ .Sizeof(T[int]{})
func (*A) m() int { return 0 }
-var _ = A.m /* ERROR invalid method expression A\.m \(needs pointer receiver \(\*A\)\.m\) */ ()
+var _ = A.m /* ERROR "invalid method expression A\.m \(needs pointer receiver \(\*A\)\.m\)" */ ()
var _ = (*A).m(nil)
type B struct{ A }
-var _ = B.m // ERROR invalid method expression B\.m \(needs pointer receiver \(\*B\)\.m\)
+var _ = B.m // ERROR "invalid method expression B\.m \(needs pointer receiver \(\*B\)\.m\)"
var _ = (*B).m
-var _ = struct{ A }.m // ERROR invalid method expression struct{A}\.m \(needs pointer receiver \(\*struct{A}\)\.m\)
+var _ = struct{ A }.m // ERROR "invalid method expression struct{A}\.m \(needs pointer receiver \(\*struct{A}\)\.m\)"
package p
-const C = 912_345_678_901_234_567_890_123_456_789_012_345_678_901_234_567_890_912_345_678_901_234_567_890_123_456_789_012_345_678_901_234_567_890_912_345_678_901_234_567_890_123_456_789_012_345_678_901_234_567_890_912 // ERROR constant overflow
+const C = 912_345_678_901_234_567_890_123_456_789_012_345_678_901_234_567_890_912_345_678_901_234_567_890_123_456_789_012_345_678_901_234_567_890_912_345_678_901_234_567_890_123_456_789_012_345_678_901_234_567_890_912 // ERROR "constant overflow"
package p
var x struct {
- f *NotAType /* ERROR undefined */
+ f *NotAType /* ERROR "undefined" */
}
var _ = x.f == nil // no error expected here
-var y *NotAType /* ERROR undefined */
+var y *NotAType /* ERROR "undefined" */
var _ = y == nil // no error expected here
package p
func _(s []int) {
- clear /* ERROR clear requires go1\.21 or later */ (s)
+ clear /* ERROR "clear requires go1\.21 or later" */ (s)
}
}
type B[T any] interface {
- B /* ERROR invalid recursive type */ [*T]
+ B /* ERROR "invalid recursive type" */ [*T]
}
type C[T any, U B[U]] interface {
// Simplified reproducer:
type X[T any] interface {
- X /* ERROR invalid recursive type */ [*T]
+ X /* ERROR "invalid recursive type" */ [*T]
}
var _ X[int]
// A related example that doesn't go through interfaces.
-type A2[P any] [10]A2 /* ERROR invalid recursive type */ [*P]
+type A2[P any] [10]A2 /* ERROR "invalid recursive type" */ [*P]
var _ A2[int]
func f[T C]() {}
func _() {
- _ = f[[ /* ERROR \[2\]any does not satisfy C \(C mentions \[2\]any, but \[2\]any is not in the type set of C\) */ 2]any]
+ _ = f[[ /* ERROR "\[2\]any does not satisfy C \(C mentions \[2\]any, but \[2\]any is not in the type set of C\)" */ 2]any]
}
type U4 interface { M; M; M }
type U5 interface { U1; U2; U3; U4 }
-type U6 interface { m(); m /* ERROR duplicate method */ () }
-type U7 interface { M32 /* ERROR duplicate method */ ; m() }
-type U8 interface { m(); M32 /* ERROR duplicate method */ }
-type U9 interface { M32; M64 /* ERROR duplicate method */ }
+type U6 interface { m(); m /* ERROR "duplicate method" */ () }
+type U7 interface { M32 /* ERROR "duplicate method" */ ; m() }
+type U8 interface { m(); M32 /* ERROR "duplicate method" */ }
+type U9 interface { M32; M64 /* ERROR "duplicate method" */ }
// Verify that repeated embedding of the same interface(s)
// eliminates duplicate methods early (rather than at the
// and at least one of V or T is not a named type."
// (here a named type is a type with a name)
func _[TP1, TP2 Interface](X1 TP1, X2 TP2) {
- b = B // ERROR cannot use B .* as int value
+ b = B // ERROR "cannot use B .* as int value"
a = A
l = L
s = S
c = C
d = D
- B = b // ERROR cannot use b .* as Basic value
+ B = b // ERROR "cannot use b .* as Basic value"
A = a
L = l
S = s
M = m
C = c
D = d
- X1 = i // ERROR cannot use i .* as TP1 value
- X1 = X2 // ERROR cannot use X2 .* as TP1 value
+ X1 = i // ERROR "cannot use i .* as TP1 value"
+ X1 = X2 // ERROR "cannot use X2 .* as TP1 value"
}
// "T is an interface type and x implements T and T is not a type parameter"
func _[TP Interface](X TP) {
- i = d // ERROR missing method m
+ i = d // ERROR "missing method m"
i = D
i = X
- X = i // ERROR cannot use i .* as TP value
+ X = i // ERROR "cannot use i .* as TP value"
}
// "x is a bidirectional channel value, T is a channel type, x's type V and T have identical element types, and at least one of V or T is not a named type"
_ RecvChan = c
_ Chan = c
- _ SendChan = C // ERROR cannot use C .* as SendChan value
- _ RecvChan = C // ERROR cannot use C .* as RecvChan value
+ _ SendChan = C // ERROR "cannot use C .* as SendChan value"
+ _ RecvChan = C // ERROR "cannot use C .* as RecvChan value"
_ Chan = C
- _ Chan = make /* ERROR cannot use make\(chan Basic\) .* as Chan value */ (chan Basic)
+ _ Chan = make /* ERROR "cannot use make\(chan Basic\) .* as Chan value" */ (chan Basic)
)
var (
- _ _CC = C // ERROR cannot use C .* as _CC value
- _ _SC = C // ERROR cannot use C .* as _SC value
- _ _RC = C // ERROR cannot use C .* as _RC value
+ _ _CC = C // ERROR "cannot use C .* as _CC value"
+ _ _SC = C // ERROR "cannot use C .* as _SC value"
+ _ _RC = C // ERROR "cannot use C .* as _RC value"
- _ CC = _CC /* ERROR cannot use _CC\(nil\) .* as CC value */ (nil)
- _ SC = _CC /* ERROR cannot use _CC\(nil\) .* as SC value */ (nil)
- _ RC = _CC /* ERROR cannot use _CC\(nil\) .* as RC value */ (nil)
+ _ CC = _CC /* ERROR "cannot use _CC\(nil\) .* as CC value" */ (nil)
+ _ SC = _CC /* ERROR "cannot use _CC\(nil\) .* as SC value" */ (nil)
+ _ RC = _CC /* ERROR "cannot use _CC\(nil\) .* as RC value" */ (nil)
- _ CC = C // ERROR cannot use C .* as CC value
- _ SC = C // ERROR cannot use C .* as SC value
- _ RC = C // ERROR cannot use C .* as RC value
+ _ CC = C // ERROR "cannot use C .* as CC value"
+ _ SC = C // ERROR "cannot use C .* as SC value"
+ _ RC = C // ERROR "cannot use C .* as RC value"
)
}
TP2 ~chan int | ~chan byte,
]() {
var (
- _ TP0 = c // ERROR cannot use c .* as TP0 value
- _ TP0 = C // ERROR cannot use C .* as TP0 value
+ _ TP0 = c // ERROR "cannot use c .* as TP0 value"
+ _ TP0 = C // ERROR "cannot use C .* as TP0 value"
_ TP1 = c
- _ TP1 = C // ERROR cannot use C .* as TP1 value
- _ TP2 = c // ERROR .* cannot assign chan int to chan byte
+ _ TP1 = C // ERROR "cannot use C .* as TP1 value"
+ _ TP2 = c // ERROR ".* cannot assign chan int to chan byte"
)
}
i = X0
I = X0
c = X1
- C = X1 // ERROR cannot use X1 .* as Chan value
- c = X2 // ERROR .* cannot assign chan byte \(in TP2\) to chan int
+ C = X1 // ERROR "cannot use X1 .* as Chan value"
+ c = X2 // ERROR ".* cannot assign chan byte \(in TP2\) to chan int"
}
// "x is the predeclared identifier nil and T is a pointer, function, slice, map, channel, or interface type"
func _[TP Interface](X TP) {
- b = nil // ERROR cannot use nil
- a = nil // ERROR cannot use nil
+ b = nil // ERROR "cannot use nil"
+ a = nil // ERROR "cannot use nil"
l = nil
- s = nil // ERROR cannot use nil
+ s = nil // ERROR "cannot use nil"
p = nil
f = nil
i = nil
m = nil
c = nil
- d = nil // ERROR cannot use nil
+ d = nil // ERROR "cannot use nil"
- B = nil // ERROR cannot use nil
- A = nil // ERROR cannot use nil
+ B = nil // ERROR "cannot use nil"
+ A = nil // ERROR "cannot use nil"
L = nil
- S = nil // ERROR cannot use nil
+ S = nil // ERROR "cannot use nil"
P = nil
F = nil
I = nil
M = nil
C = nil
- D = nil // ERROR cannot use nil
- X = nil // ERROR cannot use nil
+ D = nil // ERROR "cannot use nil"
+ X = nil // ERROR "cannot use nil"
}
// "x is an untyped constant representable by a value of type T"
i8_16 = -1 << 7
i8_16 = 1<<7 - 1
- i8_16 = - /* ERROR cannot use .* as Int8_16 */ 1 << 15
- i8_16 = 1 /* ERROR cannot use .* as Int8_16 */ <<15 - 1
+ i8_16 = - /* ERROR "cannot use .* as Int8_16" */ 1 << 15
+ i8_16 = 1 /* ERROR "cannot use .* as Int8_16" */ <<15 - 1
}
// proto-types for tests
_ = f1[any /* any does satisfy comparable */]
_ = f1[P]
_ = f1[Q]
- _ = f1[R /* ERROR R does not satisfy comparable */]
+ _ = f1[R /* ERROR "R does not satisfy comparable" */]
_ = f2[int]
_ = f2[T /* T does satisfy comparable */]
_ = f2[any /* any does satisfy comparable */]
_ = f2[P]
_ = f2[Q]
- _ = f2[R /* ERROR R does not satisfy comparable */]
+ _ = f2[R /* ERROR "R does not satisfy comparable" */]
}
func _[P comparable, Q ~int, R any]() {
_ = f1[int]
- _ = f1[T /* ERROR T to satisfy comparable requires go1\.20 or later */]
- _ = f1[any /* ERROR any to satisfy comparable requires go1\.20 or later */]
+ _ = f1[T /* ERROR "T to satisfy comparable requires go1\.20 or later" */]
+ _ = f1[any /* ERROR "any to satisfy comparable requires go1\.20 or later" */]
_ = f1[P]
_ = f1[Q]
- _ = f1[R /* ERROR R does not satisfy comparable */]
+ _ = f1[R /* ERROR "R does not satisfy comparable" */]
_ = f2[int]
- _ = f2[T /* ERROR T to satisfy comparable requires go1\.20 or later */]
- _ = f2[any /* ERROR any to satisfy comparable requires go1\.20 or later */]
+ _ = f2[T /* ERROR "T to satisfy comparable requires go1\.20 or later" */]
+ _ = f2[any /* ERROR "any to satisfy comparable requires go1\.20 or later" */]
_ = f2[P]
_ = f2[Q]
- _ = f2[R /* ERROR R does not satisfy comparable */]
+ _ = f2[R /* ERROR "R does not satisfy comparable" */]
}
)
func _() {
- _ = nil == nil // ERROR operator == not defined on untyped nil
+ _ = nil == nil // ERROR "operator == not defined on untyped nil"
_ = b == b
- _ = a /* ERROR \[10\]func\(\) cannot be compared */ == a
- _ = l /* ERROR slice can only be compared to nil */ == l
- _ = s /* ERROR struct containing \[\]byte cannot be compared */ == s
+ _ = a /* ERROR "\[10\]func\(\) cannot be compared" */ == a
+ _ = l /* ERROR "slice can only be compared to nil" */ == l
+ _ = s /* ERROR "struct containing \[\]byte cannot be compared" */ == s
_ = p == p
- _ = f /* ERROR func can only be compared to nil */ == f
+ _ = f /* ERROR "func can only be compared to nil" */ == f
_ = i == i
- _ = m /* ERROR map can only be compared to nil */ == m
+ _ = m /* ERROR "map can only be compared to nil" */ == m
_ = c == c
- _ = b == nil /* ERROR mismatched types */
- _ = a == nil /* ERROR mismatched types */
+ _ = b == nil /* ERROR "mismatched types" */
+ _ = a == nil /* ERROR "mismatched types" */
_ = l == nil
- _ = s == nil /* ERROR mismatched types */
+ _ = s == nil /* ERROR "mismatched types" */
_ = p == nil
_ = f == nil
_ = i == nil
_ = m == nil
_ = c == nil
- _ = nil /* ERROR operator < not defined on untyped nil */ < nil
+ _ = nil /* ERROR "operator < not defined on untyped nil" */ < nil
_ = b < b
- _ = a /* ERROR operator < not defined on array */ < a
- _ = l /* ERROR operator < not defined on slice */ < l
- _ = s /* ERROR operator < not defined on struct */ < s
- _ = p /* ERROR operator < not defined on pointer */ < p
- _ = f /* ERROR operator < not defined on func */ < f
- _ = i /* ERROR operator < not defined on interface */ < i
- _ = m /* ERROR operator < not defined on map */ < m
- _ = c /* ERROR operator < not defined on chan */ < c
+ _ = a /* ERROR "operator < not defined on array" */ < a
+ _ = l /* ERROR "operator < not defined on slice" */ < l
+ _ = s /* ERROR "operator < not defined on struct" */ < s
+ _ = p /* ERROR "operator < not defined on pointer" */ < p
+ _ = f /* ERROR "operator < not defined on func" */ < f
+ _ = i /* ERROR "operator < not defined on interface" */ < i
+ _ = m /* ERROR "operator < not defined on map" */ < m
+ _ = c /* ERROR "operator < not defined on chan" */ < c
}
func _[
c C,
) {
_ = b == b
- _ = a /* ERROR incomparable types in type set */ == a
- _ = l /* ERROR incomparable types in type set */ == l
- _ = s /* ERROR incomparable types in type set */ == s
+ _ = a /* ERROR "incomparable types in type set" */ == a
+ _ = l /* ERROR "incomparable types in type set" */ == l
+ _ = s /* ERROR "incomparable types in type set" */ == s
_ = p == p
- _ = f /* ERROR incomparable types in type set */ == f
- _ = i /* ERROR incomparable types in type set */ == i
+ _ = f /* ERROR "incomparable types in type set" */ == f
+ _ = i /* ERROR "incomparable types in type set" */ == i
_ = j == j
- _ = m /* ERROR incomparable types in type set */ == m
+ _ = m /* ERROR "incomparable types in type set" */ == m
_ = c == c
- _ = b == nil /* ERROR mismatched types */
- _ = a == nil /* ERROR mismatched types */
+ _ = b == nil /* ERROR "mismatched types" */
+ _ = a == nil /* ERROR "mismatched types" */
_ = l == nil
- _ = s == nil /* ERROR mismatched types */
+ _ = s == nil /* ERROR "mismatched types" */
_ = p == nil
_ = f == nil
- _ = i == nil /* ERROR mismatched types */
- _ = j == nil /* ERROR mismatched types */
+ _ = i == nil /* ERROR "mismatched types" */
+ _ = j == nil /* ERROR "mismatched types" */
_ = m == nil
_ = c == nil
_ = b < b
- _ = a /* ERROR type parameter A is not comparable with < */ < a
- _ = l /* ERROR type parameter L is not comparable with < */ < l
- _ = s /* ERROR type parameter S is not comparable with < */ < s
- _ = p /* ERROR type parameter P is not comparable with < */ < p
- _ = f /* ERROR type parameter F is not comparable with < */ < f
- _ = i /* ERROR type parameter I is not comparable with < */ < i
- _ = j /* ERROR type parameter J is not comparable with < */ < j
- _ = m /* ERROR type parameter M is not comparable with < */ < m
- _ = c /* ERROR type parameter C is not comparable with < */ < c
+ _ = a /* ERROR "type parameter A is not comparable with <" */ < a
+ _ = l /* ERROR "type parameter L is not comparable with <" */ < l
+ _ = s /* ERROR "type parameter S is not comparable with <" */ < s
+ _ = p /* ERROR "type parameter P is not comparable with <" */ < p
+ _ = f /* ERROR "type parameter F is not comparable with <" */ < f
+ _ = i /* ERROR "type parameter I is not comparable with <" */ < i
+ _ = j /* ERROR "type parameter J is not comparable with <" */ < j
+ _ = m /* ERROR "type parameter M is not comparable with <" */ < m
+ _ = c /* ERROR "type parameter C is not comparable with <" */ < c
}
// constant conversions
func _[T ~byte]() T { return 255 }
-func _[T ~byte]() T { return 256 /* ERROR cannot use 256 .* as T value */ }
+func _[T ~byte]() T { return 256 /* ERROR "cannot use 256 .* as T value" */ }
func _[T ~byte]() {
- const _ = T /* ERROR T\(0\) .* is not constant */ (0)
+ const _ = T /* ERROR "T\(0\) .* is not constant" */ (0)
var _ T = 255
- var _ T = 256 // ERROR cannot use 256 .* as T value
+ var _ T = 256 // ERROR "cannot use 256 .* as T value"
}
func _[T ~string]() T { return T('a') }
func _[T ~int | ~string]() T { return T('a') }
-func _[T ~byte | ~int | ~string]() T { return T(256 /* ERROR cannot convert 256 .* to type T */) }
+func _[T ~byte | ~int | ~string]() T { return T(256 /* ERROR "cannot convert 256 .* to type T" */) }
// implicit conversions never convert to string
func _[T ~string]() {
- var _ string = 0 // ERROR cannot use .* as string value
- var _ T = 0 // ERROR cannot use .* as T value
+ var _ string = 0 // ERROR "cannot use .* as string value"
+ var _ T = 0 // ERROR "cannot use .* as T value"
}
// failing const conversions of constants to type parameters report a cause
T3 ~int | ~float64 | ~bool,
T4 ~int | ~string,
]() {
- _ = T1(0 /* ERROR cannot convert 0 .* to type T1: T1 does not contain specific types */)
- _ = T2(1 /* ERROR cannot convert 1 .* to type T2: T2 does not contain specific types */)
- _ = T3(2 /* ERROR cannot convert 2 .* to type T3: cannot convert 2 .* to type bool \(in T3\) */)
- _ = T4(3.14 /* ERROR cannot convert 3.14 .* to type T4: cannot convert 3.14 .* to type int \(in T4\) */)
+ _ = T1(0 /* ERROR "cannot convert 0 .* to type T1: T1 does not contain specific types" */)
+ _ = T2(1 /* ERROR "cannot convert 1 .* to type T2: T2 does not contain specific types" */)
+ _ = T3(2 /* ERROR "cannot convert 2 .* to type T3: cannot convert 2 .* to type bool \(in T3\)" */)
+ _ = T4(3.14 /* ERROR "cannot convert 3.14 .* to type T4: cannot convert 3.14 .* to type int \(in T4\)" */)
}
// "x is assignable to T"
func _[X Foo | Bar, T Bar](x X) T { return T(x) }
func _[X Foo, T Foo | Bar](x X) T { return T(x) }
func _[X Foo, T Far](x X) T {
- return T(x /* ERROR cannot convert x \(variable of type X constrained by Foo\) to type T: cannot convert Foo \(in X\) to type Far \(in T\) */)
+ return T(x /* ERROR "cannot convert x \(variable of type X constrained by Foo\) to type T: cannot convert Foo \(in X\) to type Far \(in T\)" */)
}
// "x's type and T are unnamed pointer types and their pointer base types
func _[X ~*Foo | ~*Bar, T ~*Bar](x X) T { return T(x) }
func _[X ~*Foo, T ~*Foo | ~*Bar](x X) T { return T(x) }
func _[X ~*Foo, T ~*Far](x X) T {
- return T(x /* ERROR cannot convert x \(variable of type X constrained by ~\*Foo\) to type T: cannot convert \*Foo \(in X\) to type \*Far \(in T\) */)
+ return T(x /* ERROR "cannot convert x \(variable of type X constrained by ~\*Foo\) to type T: cannot convert \*Foo \(in X\) to type \*Far \(in T\)" */)
}
// Verify that the defined types in constraints are considered for the rule above.
T0 *C
)
-func _(x X0) T0 { return T0(x /* ERROR cannot convert */) } // non-generic reference
-func _[X X0, T T0](x X) T { return T(x /* ERROR cannot convert */) }
-func _[T T0](x X0) T { return T(x /* ERROR cannot convert */) }
-func _[X X0](x X) T0 { return T0(x /* ERROR cannot convert */) }
+func _(x X0) T0 { return T0(x /* ERROR "cannot convert" */) } // non-generic reference
+func _[X X0, T T0](x X) T { return T(x /* ERROR "cannot convert" */) }
+func _[T T0](x X0) T { return T(x /* ERROR "cannot convert" */) }
+func _[X X0](x X) T0 { return T0(x /* ERROR "cannot convert" */) }
// "x's type and T are both integer or floating point types"
func _[X, T Integer | Unsigned | Float](x X) T { return T(x) }
func _[X, T Integer | ~string](x X) T {
- return T(x /* ERROR cannot convert x \(variable of type X constrained by Integer \| ~string\) to type T: cannot convert string \(in X\) to type int \(in T\) */)
+ return T(x /* ERROR "cannot convert x \(variable of type X constrained by Integer \| ~string\) to type T: cannot convert string \(in X\) to type int \(in T\)" */)
}
// "x's type and T are both complex types"
func _[X, T Complex](x X) T { return T(x) }
func _[X, T Float | Complex](x X) T {
- return T(x /* ERROR cannot convert x \(variable of type X constrained by Float \| Complex\) to type T: cannot convert float32 \(in X\) to type complex64 \(in T\) */)
+ return T(x /* ERROR "cannot convert x \(variable of type X constrained by Float \| Complex\) to type T: cannot convert float32 \(in X\) to type complex64 \(in T\)" */)
}
// "x is an integer or a slice of bytes or runes and T is a string type"
func _[X Integer](x X) string { return string(x) }
func _[X Integer](x X) myString { return myString(x) }
func _[X Integer](x X) *string {
- return (*string)(x /* ERROR cannot convert x \(variable of type X constrained by Integer\) to type \*string: cannot convert int \(in X\) to type \*string */)
+ return (*string)(x /* ERROR "cannot convert x \(variable of type X constrained by Integer\) to type \*string: cannot convert int \(in X\) to type \*string" */)
}
func _[T ~string](x []byte) T { return T(x) }
func _[X ~[]rune, T ~string](x X) T { return T(x) }
func _[X Integer | ~[]byte | ~[]rune, T ~string](x X) T { return T(x) }
func _[X Integer | ~[]byte | ~[]rune, T ~*string](x X) T {
- return T(x /* ERROR cannot convert x \(variable of type X constrained by Integer \| ~\[\]byte \| ~\[\]rune\) to type T: cannot convert int \(in X\) to type \*string \(in T\) */)
+ return T(x /* ERROR "cannot convert x \(variable of type X constrained by Integer \| ~\[\]byte \| ~\[\]rune\) to type T: cannot convert int \(in X\) to type \*string \(in T\)" */)
}
// "x is a string and T is a slice of bytes or runes"
func _[T ~[]byte](x string) T { return T(x) }
func _[T ~[]rune](x string) T { return T(x) }
func _[T ~[]rune](x *string) T {
- return T(x /* ERROR cannot convert x \(variable of type \*string\) to type T: cannot convert \*string to type \[\]rune \(in T\) */)
+ return T(x /* ERROR "cannot convert x \(variable of type \*string\) to type T: cannot convert \*string to type \[\]rune \(in T\)" */)
}
func _[X ~string, T ~[]byte](x X) T { return T(x) }
func _[X ~string, T ~[]rune](x X) T { return T(x) }
func _[X ~string, T ~[]byte | ~[]rune](x X) T { return T(x) }
func _[X ~*string, T ~[]byte | ~[]rune](x X) T {
- return T(x /* ERROR cannot convert x \(variable of type X constrained by ~\*string\) to type T: cannot convert \*string \(in X\) to type \[\]byte \(in T\) */)
+ return T(x /* ERROR "cannot convert x \(variable of type X constrained by ~\*string\) to type T: cannot convert \*string \(in X\) to type \[\]byte \(in T\)" */)
}
// package unsafe:
func _[X ~uintptr](x X) unsafe.Pointer { return unsafe.Pointer(x) }
func _[T unsafe.Pointer](x myUintptr) T { return T(x) }
func _[T unsafe.Pointer](x int64) T {
- return T(x /* ERROR cannot convert x \(variable of type int64\) to type T: cannot convert int64 to type unsafe\.Pointer \(in T\) */)
+ return T(x /* ERROR "cannot convert x \(variable of type int64\) to type T: cannot convert int64 to type unsafe\.Pointer \(in T\)" */)
}
// "and vice versa"
func _[X unsafe.Pointer](x X) uintptr { return uintptr(x) }
func _[X unsafe.Pointer](x X) myUintptr { return myUintptr(x) }
func _[X unsafe.Pointer](x X) int64 {
- return int64(x /* ERROR cannot convert x \(variable of type X constrained by unsafe\.Pointer\) to type int64: cannot convert unsafe\.Pointer \(in X\) to type int64 */)
+ return int64(x /* ERROR "cannot convert x \(variable of type X constrained by unsafe\.Pointer\) to type int64: cannot convert unsafe\.Pointer \(in X\) to type int64" */)
}
// "x is a slice, T is an array or pointer-to-array type,
func _[P comparable, Q ~int, R any]() {
_ = f1[int]
- _ = f1[T /* ERROR T does not satisfy comparable */]
- _ = f1[any /* ERROR any does not satisfy comparable */]
+ _ = f1[T /* ERROR "T does not satisfy comparable" */]
+ _ = f1[any /* ERROR "any does not satisfy comparable" */]
_ = f1[P]
_ = f1[Q]
- _ = f1[R /* ERROR R does not satisfy comparable */]
+ _ = f1[R /* ERROR "R does not satisfy comparable" */]
_ = f2[int]
- _ = f2[T /* ERROR T does not satisfy comparable */]
- _ = f2[any /* ERROR any does not satisfy comparable */]
+ _ = f2[T /* ERROR "T does not satisfy comparable" */]
+ _ = f2[any /* ERROR "any does not satisfy comparable" */]
_ = f2[P]
_ = f2[Q]
- _ = f2[R /* ERROR R does not satisfy comparable */]
+ _ = f2[R /* ERROR "R does not satisfy comparable" */]
}