golang/go

go/types: can shift complex numbers

dvyukov opened this issue · 5 comments

gotype successfully compiles the following program:

package a
var a = complex64(1) << 2

gccgo also compiles it. gc rejects it saying:

invalid operation: complex64(1) << 2 (shift of type complex64)

Spec says that lhs of shift must be an integer.

@griesemer if my reading of the spec is correct, then we also need to file a bug on gccgo.

This is clearly a go/types bug. Should be trivial to fix and probably should be fixed for 1.5.

The fix is trivial (one missing predicate check). Can safely go in for 1.5 as far as I am concerned.

https://go-review.googlesource.com/#/c/12045/

(includes tests).

CL https://golang.org/cl/12045 mentions this issue.

CL https://golang.org/cl/12046 mentions this issue.