blob: 4ead815158f61e2dbbb91dec8e7feabef4a3923c (
plain)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
// Copyright 2012 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.
// binary expressions
package expr1
type mybool bool
func _(x, y bool, z mybool) {
x = x || y
x = x || true
x = x || false
x = x && y
x = x && true
x = x && false
z = z /* ERROR mismatched types */ || y
z = z || true
z = z || false
z = z /* ERROR mismatched types */ && y
z = z && true
z = z && false
}
type myint int
func _(x, y int, z myint) {
x = x + 1
x = x + 1.0
x = x + 1.1 // ERROR truncated to int
x = x + y
x = x - y
x = x * y
x = x / y
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 << y
z = z >> y
}
type myuint uint
func _(x, y uint, z myuint) {
x = x + 1
x = x + - /* ERROR overflows uint */ 1
x = x + 1.0
x = x + 1.1 // ERROR truncated to uint
x = x + y
x = x - y
x = x * y
x = x / y
x = x % y
x = x << y
x = x >> y
z = z + 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 << y
z = z >> y
}
type myfloat64 float64
func _(x, y float64, z myfloat64) {
x = x + 1
x = x + -1
x = x + 1.0
x = x + 1.1
x = x + 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
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
}
type mystring string
func _(x, y string, z mystring) {
x = x + "foo"
x = x /* ERROR not defined */ - "foo"
x = x + 1 // ERROR cannot convert
x = x + y
x = x /* ERROR not defined */ - y
x = x * 10 // ERROR cannot convert
}
func f() (a, b int) { return }
func _(x int) {
_ = f /* ERROR 2-valued f */ () + 1
_ = x + f /* ERROR 2-valued f */ ()
_ = f /* ERROR 2-valued f */ () + f
_ = f /* ERROR 2-valued f */ () + f /* ERROR 2-valued f */ ()
}
|