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: constdecl.go
// Copyright 2013 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. package constdecl import "math" import "unsafe" var v int // Const decls must be initialized by constants. const _ = v /* ERROR "not constant" */ const _ = math /* ERROR "not constant" */ .Sin(0) const _ = int /* ERROR "not an expression" */ func _() { const _ = v /* ERROR "not constant" */ const _ = math /* ERROR "not constant" */ .Sin(0) const _ = int /* ERROR "not an expression" */ } // Identifier and expression arity must match. const _ /* ERROR "missing init expr for _" */ const _ = 1, 2 /* ERROR "extra init expr 2" */ const _ /* ERROR "missing init expr for _" */ int const _ int = 1, 2 /* ERROR "extra init expr 2" */ const ( _ /* ERROR "missing init expr for _" */ _ = 1, 2 /* ERROR "extra init expr 2" */ _ /* ERROR "missing init expr for _" */ int _ int = 1, 2 /* ERROR "extra init expr 2" */ ) const ( _ = 1 _ _, _ /* ERROR "missing init expr for _" */ _ ) const ( _, _ = 1, 2 _, _ _ /* ERROR "extra init expr at" */ _, _ _, _, _ /* ERROR "missing init expr for _" */ _, _ ) func _() { const _ /* ERROR "missing init expr for _" */ const _ = 1, 2 /* ERROR "extra init expr 2" */ const _ /* ERROR "missing init expr for _" */ int const _ int = 1, 2 /* ERROR "extra init expr 2" */ const ( _ /* ERROR "missing init expr for _" */ _ = 1, 2 /* ERROR "extra init expr 2" */ _ /* ERROR "missing init expr for _" */ int _ int = 1, 2 /* ERROR "extra init expr 2" */ ) const ( _ = 1 _ _, _ /* ERROR "missing init expr for _" */ _ ) const ( _, _ = 1, 2 _, _ _ /* ERROR "extra init expr at" */ _, _ _, _, _ /* ERROR "missing init expr for _" */ _, _ ) } // Test case for constant with invalid initialization. // Caused panic because the constant value was not set up (gri - 7/8/2014). func _() { const ( x string = missing /* ERROR "undeclared name" */ y = x + "" ) } // Test case for constants depending on function literals (see also #22992). const A /* ERROR initialization cycle */ = unsafe.Sizeof(func() { _ = A }) func _() { // The function literal below must not see a. const a = unsafe.Sizeof(func() { _ = a /* ERROR "undeclared name" */ }) const b = unsafe.Sizeof(func() { _ = a }) // The function literal below must not see x, y, or z. const x, y, z = 0, 1, unsafe.Sizeof(func() { _ = x /* ERROR "undeclared name" */ + y /* ERROR "undeclared name" */ + z /* ERROR "undeclared name" */ }) } // Test cases for errors in inherited constant initialization expressions. // Errors related to inherited initialization expressions must appear at // the constant identifier being declared, not at the original expression // (issues #42991, #42992). const ( _ byte = 255 + iota /* some gap */ _ // ERROR overflows /* some gap */ /* some gap */ _ /* ERROR overflows */; _ /* ERROR overflows */ /* some gap */ _ = 255 + iota _ = byte /* ERROR overflows */ (255) + iota _ /* ERROR overflows */ ) // Test cases from issue. const ( ok = byte(iota + 253) bad barn bard // ERROR cannot convert ) const ( c = len([1 - iota]int{}) d e // ERROR invalid array length f // ERROR invalid array length ) // Test that identifiers in implicit (omitted) RHS // expressions of constant declarations are resolved // in the correct context; see issues #49157, #53585. const X = 2 func _() { const ( A = iota // 0 iota = iota // 1 B // 1 (iota is declared locally on prev. line) C // 1 ) assert(A == 0 && B == 1 && C == 1) const ( X = X + X Y Z = iota ) assert(X == 4 && Y == 8 && Z == 1) } // TODO(gri) move extra tests from testdata/const0.src into here
Upload File
Create Folder