]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix wrong condition in tcShift
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 4 Mar 2021 15:27:41 +0000 (22:27 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 5 Mar 2021 18:46:48 +0000 (18:46 +0000)
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>
src/cmd/compile/internal/typecheck/expr.go
test/fixedbugs/bug297.go

index 339fb00aa449647c6b47a9421938ff99642e856d..10a4c1b1dc14792aeaa76e8445fc40695d76a2cb 100644 (file)
@@ -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
        }
 
index c2bd253d056eac03045250d3d29fa89ba79ac2cf..70eb4ca9b26807ca7564af83f370b65e923bd408 100644 (file)
@@ -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"
 )