Source file test/fixedbugs/issue6671.go

     1  // errorcheck
     2  
     3  // Copyright 2014 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  // Issue 6671: Logical operators should produce untyped bool for untyped operands.
     8  
     9  package p
    10  
    11  type mybool bool
    12  
    13  func _(x, y int) {
    14  	type mybool bool
    15  	var b mybool
    16  	_ = b
    17  	b = bool(true)             // ERROR "cannot use"
    18  	b = true                   // permitted as expected
    19  	b = bool(true) && true     // ERROR "cannot use"
    20  	b = true && true           // permitted => && returns an untyped bool
    21  	b = x < y                  // permitted => x < y returns an untyped bool
    22  	b = true && x < y          // permitted => result of && returns untyped bool
    23  	b = x < y && x < y         // permitted => result of && returns untyped bool
    24  	b = x < y || x < y         // permitted => result of || returns untyped bool
    25  	var c bool = true && x < y // permitted => result of && is bool
    26  	c = false || x < y         // permitted => result of || returns untyped bool
    27  	_ = c
    28  }
    29  

View as plain text