]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix typechecking logical operators panic with non-boolean operand
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 27 Apr 2021 16:01:16 +0000 (23:01 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 28 Apr 2021 00:49:58 +0000 (00:49 +0000)
commitc9f43507c6d8106646b1262052cc9a2c5dbb6e4c
tree414c512dcb4c5ebba5ecad15e101ff331a9674cc
parent983dea90c169930e35721232afe39fd4e3fbe4a6
cmd/compile: fix typechecking logical operators panic with non-boolean operand

In CL 255899, we added code to make clearer error when non-bool used
as operand to logical operators. The code is safe, because node type
is guaranteed to be non-nil.

In CL 279442, we refactored typechecking arith, including moving
typechecking logical operators to separate case. Now we have to
explicitly check if operand type is not nil, because calling Expr can
set operand type nil for non-bool operands.

Fixes #45804

Change-Id: Ie2b6e18f65c0614a803b343f60e78ee1d660bbeb
Reviewed-on: https://go-review.googlesource.com/c/go/+/314209
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/typecheck.go
test/fixedbugs/issue45804.go [new file with mode: 0644]