File: init0.src

package info (click to toggle)
golang-go.tools 0.0~hg20140703-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,060 kB
  • ctags: 5,784
  • sloc: asm: 622; sh: 179; lisp: 157; makefile: 37; xml: 11
file content (106 lines) | stat: -rw-r--r-- 1,947 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// 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.

// initialization cycles

package init0

// initialization cycles (we don't know the types)
const (
	s0 /* ERROR initialization cycle */ = s0

	x0 /* ERROR initialization cycle */ = y0
	y0 = x0

	a0 = b0
	b0 /* ERROR initialization cycle */ = c0
	c0 = d0
	d0 = b0
)

var (
	s1 /* ERROR initialization cycle */ = s1

	x1 /* ERROR initialization cycle */ = y1
	y1 = x1

	a1 = b1
	b1 /* ERROR initialization cycle */ = c1
	c1 = d1
	d1 = b1
)

// initialization cycles (we know the types)
const (
	s2 /* ERROR initialization cycle */ int = s2

	x2 /* ERROR initialization cycle */ int = y2
	y2 = x2

	a2 = b2
	b2 /* ERROR initialization cycle */ int = c2
	c2 = d2
	d2 = b2
)

var (
	s3 /* ERROR initialization cycle */ int = s3

	x3 /* ERROR initialization cycle */ int = y3
	y3 = x3

	a3 = b3
	b3 /* ERROR initialization cycle */ int = c3
	c3 = d3
	d3 = b3
)

// cycles via struct fields

type S1 struct {
	f int
}
const cx3 S1 /* ERROR invalid constant type */ = S1{cx3.f}
var vx3 /* ERROR initialization cycle */ S1 = S1{vx3.f}

// cycles via functions

var x4 = x5
var x5 /* ERROR initialization cycle */ = f1()
func f1() int { return x5*10 }

var x6 /* ERROR initialization cycle */ , x7 = f2()
var x8 = x7
func f2() (int, int) { return f3() + f3(), 0 }
func f3() int { return x8 }

// cycles via closures

var x9 /* ERROR initialization cycle */ = func() int { return x9 }()

var x10 /* ERROR initialization cycle */ = f4()

func f4() int {
	_ = func() {
		_ = x10
	}
	return 0
}

// cycles via method expressions

type T1 struct{}

func (T1) m() bool { _ = x11; return false }

var x11 /* ERROR initialization cycle */ = T1.m(T1{})

// cycles via method values

type T2 struct{}

func (T2) m() bool { _ = x12; return false }

var t1 T2
var x12 /* ERROR initialization cycle */ = t1.m