Skip to content

Commit fbee173

Browse files
committed
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 <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
1 parent 9e6b1fc commit fbee173

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/cmd/compile/internal/typecheck/expr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func tcAddr(n *ir.AddrExpr) ir.Node {
4848
}
4949

5050
func tcShift(n, l, r ir.Node) (ir.Node, ir.Node, *types.Type) {
51-
if l.Type() == nil || l.Type() == nil {
51+
if l.Type() == nil || r.Type() == nil {
5252
return l, r, nil
5353
}
5454

test/fixedbugs/bug297.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// errorcheck
1+
// errorcheck -d=panic
22

33
// Copyright 2010 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style
@@ -9,7 +9,8 @@
99
package main
1010

1111
type ByteSize float64
12+
1213
const (
13-
_ = iota; // ignore first value by assigning to blank identifier
14-
KB ByteSize = 1<<(10*X) // ERROR "undefined"
14+
_ = iota // ignore first value by assigning to blank identifier
15+
KB ByteSize = 1 << (10 * X) // ERROR "undefined"
1516
)

0 commit comments

Comments
 (0)