X7ROOT File Manager
Current Path:
/opt/golang/1.19.4/src/cmd/compile/internal/types2/testdata/check
opt
/
golang
/
1.19.4
/
src
/
cmd
/
compile
/
internal
/
types2
/
testdata
/
check
/
📁
..
📄
blank.go
(203 B)
📄
builtins0.go
(23.81 KB)
📄
builtins1.go
(5.46 KB)
📄
chans.go
(1.66 KB)
📄
compliterals.go
(442 B)
📄
const0.go
(9.18 KB)
📄
const1.go
(8.56 KB)
📄
constdecl.go
(3.67 KB)
📄
conversions0.go
(1.71 KB)
📄
conversions1.go
(5.07 KB)
📄
cycles0.go
(2.85 KB)
📄
cycles1.go
(781 B)
📄
cycles2.go
(1.12 KB)
📄
cycles3.go
(675 B)
📄
cycles4.go
(2.03 KB)
📄
cycles5.go
(2.98 KB)
📄
decls0.go
(3.97 KB)
📄
decls1.go
(3.6 KB)
📁
decls2
📄
decls3.go
(4.24 KB)
📄
decls4.go
(3.1 KB)
📄
decls5.go
(363 B)
📄
errors.go
(2.16 KB)
📄
expr0.go
(3.7 KB)
📄
expr1.go
(2.61 KB)
📄
expr2.go
(4.92 KB)
📄
expr3.go
(15.42 KB)
📄
funcinference.go
(2.07 KB)
📄
go1_12.go
(1.07 KB)
📄
go1_13.go
(402 B)
📄
go1_16.go
(343 B)
📄
go1_8.go
(333 B)
📄
gotos.go
(5.77 KB)
📄
importC.go
(1.23 KB)
📁
importdecl0
📁
importdecl1
📄
init0.go
(1.91 KB)
📄
init1.go
(1.46 KB)
📄
init2.go
(3.51 KB)
📁
issue25008
📄
issues0.go
(11.44 KB)
📄
issues1.go
(6.02 KB)
📄
labels.go
(3.25 KB)
📄
linalg.go
(2.24 KB)
📄
literals.go
(2.35 KB)
📄
main0.go
(361 B)
📄
main1.go
(250 B)
📄
map0.go
(2.82 KB)
📄
map1.go
(3.4 KB)
📄
methodsets.go
(3.44 KB)
📄
shifts.go
(12.62 KB)
📄
slices.go
(1.51 KB)
📄
stmt0.go
(18.68 KB)
📄
stmt1.go
(3.31 KB)
📄
typeinference.go
(1.38 KB)
📄
typeinst0.go
(1.62 KB)
📄
typeinst1.go
(5.65 KB)
📄
typeinstcycles.go
(384 B)
📄
typeparams.go
(15.06 KB)
📄
unions.go
(2.15 KB)
📄
vardecl.go
(5.47 KB)
Editing: conversions1.go
// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Test various valid and invalid struct assignments and conversions. // Does not compile. package conversions2 type I interface { m() } // conversions between structs func _() { type S struct{} type T struct{} var s S var t T var u struct{} s = s s = t // ERROR "cannot use .* in assignment" s = u s = S(s) s = S(t) s = S(u) t = u t = T(u) } func _() { type S struct{ x int } type T struct { x int "foo" } var s S var t T var u struct { x int "bar" } s = s s = t // ERROR "cannot use .* in assignment" s = u // ERROR "cannot use .* in assignment" s = S(s) s = S(t) s = S(u) t = u // ERROR "cannot use .* in assignment" t = T(u) } func _() { type E struct{ x int } type S struct{ x E } type T struct { x E "foo" } var s S var t T var u struct { x E "bar" } s = s s = t // ERROR "cannot use .* in assignment" s = u // ERROR "cannot use .* in assignment" s = S(s) s = S(t) s = S(u) t = u // ERROR "cannot use .* in assignment" t = T(u) } func _() { type S struct { x struct { x int "foo" } } type T struct { x struct { x int "bar" } "foo" } var s S var t T var u struct { x struct { x int "bar" } "bar" } s = s s = t // ERROR "cannot use .* in assignment" s = u // ERROR "cannot use .* in assignment" s = S(s) s = S(t) s = S(u) t = u // ERROR "cannot use .* in assignment" t = T(u) } func _() { type E1 struct { x int "foo" } type E2 struct { x int "bar" } type S struct{ x E1 } type T struct { x E2 "foo" } var s S var t T var u struct { x E2 "bar" } s = s s = t // ERROR "cannot use .* in assignment" s = u // ERROR "cannot use .* in assignment" s = S(s) s = S(t /* ERROR "cannot convert" */ ) s = S(u /* ERROR "cannot convert" */ ) t = u // ERROR "cannot use .* in assignment" t = T(u) } func _() { type E struct{ x int } type S struct { f func(struct { x int "foo" }) } type T struct { f func(struct { x int "bar" }) } var s S var t T var u struct{ f func(E) } s = s s = t // ERROR "cannot use .* in assignment" s = u // ERROR "cannot use .* in assignment" s = S(s) s = S(t) s = S(u /* ERROR "cannot convert" */ ) t = u // ERROR "cannot use .* in assignment" t = T(u /* ERROR "cannot convert" */ ) } // conversions between pointers to structs func _() { type S struct{} type T struct{} var s *S var t *T var u *struct{} s = s s = t // ERROR "cannot use .* in assignment" s = u // ERROR "cannot use .* in assignment" s = (*S)(s) s = (*S)(t) s = (*S)(u) t = u // ERROR "cannot use .* in assignment" t = (*T)(u) } func _() { type S struct{ x int } type T struct { x int "foo" } var s *S var t *T var u *struct { x int "bar" } s = s s = t // ERROR "cannot use .* in assignment" s = u // ERROR "cannot use .* in assignment" s = (*S)(s) s = (*S)(t) s = (*S)(u) t = u // ERROR "cannot use .* in assignment" t = (*T)(u) } func _() { type E struct{ x int } type S struct{ x E } type T struct { x E "foo" } var s *S var t *T var u *struct { x E "bar" } s = s s = t // ERROR "cannot use .* in assignment" s = u // ERROR "cannot use .* in assignment" s = (*S)(s) s = (*S)(t) s = (*S)(u) t = u // ERROR "cannot use .* in assignment" t = (*T)(u) } func _() { type S struct { x struct { x int "foo" } } type T struct { x struct { x int "bar" } "foo" } var s *S var t *T var u *struct { x struct { x int "bar" } "bar" } s = s s = t // ERROR "cannot use .* in assignment" s = u // ERROR "cannot use .* in assignment" s = (*S)(s) s = (*S)(t) s = (*S)(u) t = u // ERROR "cannot use .* in assignment" t = (*T)(u) } func _() { type E1 struct { x int "foo" } type E2 struct { x int "bar" } type S struct{ x E1 } type T struct { x E2 "foo" } var s *S var t *T var u *struct { x E2 "bar" } s = s s = t // ERROR "cannot use .* in assignment" s = u // ERROR "cannot use .* in assignment" s = (*S)(s) s = (*S)(t /* ERROR "cannot convert" */ ) s = (*S)(u /* ERROR "cannot convert" */ ) t = u // ERROR "cannot use .* in assignment" t = (*T)(u) } func _() { type E struct{ x int } type S struct { f func(struct { x int "foo" }) } type T struct { f func(struct { x int "bar" }) } var s *S var t *T var u *struct{ f func(E) } s = s s = t // ERROR "cannot use .* in assignment" s = u // ERROR "cannot use .* in assignment" s = (*S)(s) s = (*S)(t) s = (*S)(u /* ERROR "cannot convert" */ ) t = u // ERROR "cannot use .* in assignment" t = (*T)(u /* ERROR "cannot convert" */ ) } func _() { type E struct{ x int } type S struct { f func(*struct { x int "foo" }) } type T struct { f func(*struct { x int "bar" }) } var s *S var t *T var u *struct{ f func(E) } s = s s = t // ERROR "cannot use .* in assignment" s = u // ERROR "cannot use .* in assignment" s = (*S)(s) s = (*S)(t) s = (*S)(u /* ERROR "cannot convert" */ ) t = u // ERROR "cannot use .* in assignment" t = (*T)(u /* ERROR "cannot convert" */ ) }
Upload File
Create Folder