-
Matthew Dempsky authored
Adding the evconst(n) call for OANDAND and OOROR in golang.org/cl/18262 was originally just to parallel the above iscmp branch, but upon further inspection it seemed odd that removing it caused test/fixedbugs/issue6671.go's var b mybool // ... b = bool(true) && true // ERROR "cannot use" to start failing (i.e., by not emitting the expected "cannot use" error). The problem is that evconst(n)'s settrue and setfalse paths always reset n.Type to idealbool, even for logical operators where n.Type should preserve the operand type. Adding the evconst(n) call for OANDAND/OOROR inadvertantly worked around this by turning the later evconst(n) call at line 2167 into a noop, so the "n.Type = t" assignment at line 739 would preserve the operand type. However, that means evconst(n) was still clobbering n.Type for ONOT, so declarations like: const _ bool = !mybool(true) were erroneously accepted. Update #13821. Change-Id: I18e37287f05398fdaeecc0f0d23984e244f025da Reviewed-on: https://go-review.googlesource.com/18362 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
27691fa4