Source file test/fixedbugs/issue41500.go

     1  // errorcheck
     2  
     3  // Copyright 2020 The Go Authors. All rights reserved.  Use of this
     4  // source code is governed by a BSD-style license that can be found in
     5  // the LICENSE file.
     6  
     7  package p
     8  
     9  type s struct {
    10  	slice []int
    11  }
    12  
    13  func f() {
    14  	var x *s
    15  
    16  	_ = x == nil || len(x.slice) // ERROR "invalid operation: .+ \(operator \|\| not defined on int\)|incompatible types|mismatched types untyped bool and int"
    17  	_ = len(x.slice) || x == nil // ERROR "invalid operation: .+ \(operator \|\| not defined on int\)|incompatible types|mismatched types int and untyped bool"
    18  	_ = x == nil && len(x.slice) // ERROR "invalid operation: .+ \(operator && not defined on int\)|incompatible types|mismatched types untyped bool and int"
    19  	_ = len(x.slice) && x == nil // ERROR "invalid operation: .+ \(operator && not defined on int\)|incompatible types|mismatched types int and untyped bool"
    20  }
    21  

View as plain text