aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2021-03-04 22:27:41 +0700
committerCuong Manh Le <cuong.manhle.vn@gmail.com>2021-03-05 18:46:48 +0000
commitfbee173545da4ecbdd80a59edcb93e6c4605241f (patch)
treef794ca0ba8057b090c96eec3ca4f1a0d18987d19
parent9e6b1fcd0a42db0f4699ff17e3b248e563f7eee4 (diff)
downloadgo-fbee173545da4ecbdd80a59edcb93e6c4605241f.tar.gz
go-fbee173545da4ecbdd80a59edcb93e6c4605241f.zip
cmd/compile: fix wrong condition in tcShift
CL 279442 refactored typecheck arithmetic operators, but using wrong condition for checking invalid rhs. Updates #43311 Change-Id: I7a03a5535b82ac4ea4806725776b0a4f7af1b79a Reviewed-on: https://go-review.googlesource.com/c/go/+/298714 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
-rw-r--r--src/cmd/compile/internal/typecheck/expr.go2
-rw-r--r--test/fixedbugs/bug297.go7
2 files changed, 5 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/typecheck/expr.go b/src/cmd/compile/internal/typecheck/expr.go
index 339fb00aa4..10a4c1b1dc 100644
--- a/src/cmd/compile/internal/typecheck/expr.go
+++ b/src/cmd/compile/internal/typecheck/expr.go
@@ -48,7 +48,7 @@ func tcAddr(n *ir.AddrExpr) ir.Node {
}
func tcShift(n, l, r ir.Node) (ir.Node, ir.Node, *types.Type) {
- if l.Type() == nil || l.Type() == nil {
+ if l.Type() == nil || r.Type() == nil {
return l, r, nil
}
diff --git a/test/fixedbugs/bug297.go b/test/fixedbugs/bug297.go
index c2bd253d05..70eb4ca9b2 100644
--- a/test/fixedbugs/bug297.go
+++ b/test/fixedbugs/bug297.go
@@ -1,4 +1,4 @@
-// errorcheck
+// errorcheck -d=panic
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
@@ -9,7 +9,8 @@
package main
type ByteSize float64
+
const (
- _ = iota; // ignore first value by assigning to blank identifier
- KB ByteSize = 1<<(10*X) // ERROR "undefined"
+ _ = iota // ignore first value by assigning to blank identifier
+ KB ByteSize = 1 << (10 * X) // ERROR "undefined"
)