| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/go/src/internal/types/testdata/check/ |
Upload File : |
// 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 /* ERRORx `operand x .* must be integer` */ << y
x = x /* ERRORx `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 /* ERRORx `operand z .* must be integer` */ << y
z = z /* ERRORx `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 + y
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" */ ()
}