-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/compile: clearer error when non-bool used as "||" and "&&" operand
Fixes #41500 Change-Id: I658d8921b7769b6e4288ca781cbdca5ff14a84ee Reviewed-on: https://go-review.googlesource.com/c/go/+/255899 Trust: Cuong Manh Le <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// errorcheck | ||
|
||
// Copyright 2020 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. | ||
|
||
package p | ||
|
||
type s struct { | ||
slice []int | ||
} | ||
|
||
func f() { | ||
var x *s | ||
|
||
_ = x == nil || len(x.slice) // ERROR "invalid operation: .+ \(operator \|\| not defined on int\)" | ||
_ = len(x.slice) || x == nil // ERROR "invalid operation: .+ \(operator \|\| not defined on int\)" | ||
_ = x == nil && len(x.slice) // ERROR "invalid operation: .+ \(operator && not defined on int\)" | ||
_ = len(x.slice) && x == nil // ERROR "invalid operation: .+ \(operator && not defined on int\)" | ||
} |