compiler: use bool for comma-ok if not already boolean
commitbb403de36aa29e5398119e78a2c96794bdd6bad8
authorIan Lance Taylor <iant@golang.org>
Fri, 24 Jun 2022 00:11:05 +0000 (23 17:11 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 24 Jun 2022 18:24:57 +0000 (24 11:24 -0700)
tree3c1d19ed12841958ec7a834e3e2ff5a51c096843
parentbb8e93eb1acae30a5fbe7e13149493ce4ccd301a
compiler: use bool for comma-ok if not already boolean

If a comma-ok variable already has a type, and that type is not a
boolean type, then set the type of the temporary variable to bool.
Otherwise we may try to convert an unnamed bool type to an interface
type, which will fail. But we don't want to always use bool, because
the type of the comma-ok variable may be a named bool type, in
which case the assignment would fail (or need an explicit conversion).

The test case is https://go.dev/cl/404496.

Fixes golang/go#52535

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/413894
gcc/go/gofrontend/MERGE
gcc/go/gofrontend/statements.cc