the answer is hidden in the spec, i believe (it's not easy to parse, so i suggest reading the whole thing):
"The right operand in a shift expression must have unsigned integer type or be an untyped constant representableby a value of type uint. If the left operand of a non-constant shift expression is an untyped constant, it is first converted to the type it would assume if the shift expression were replaced by its left operand alone." https://golang.org/ref/spec#Operators and then in the section Constant Expressions: "A constant comparison always yields an untyped boolean constant. If the left operand of a constant shift expression is an untyped constant, the result is an integer constant; otherwise it is a constant of the same type as the left operand, which must be of integer type." https://golang.org/ref/spec#Constant_expressions I believe an example of your case as an "illegal" in the section Operators will be beneficial. On Wed, Mar 7, 2018 at 1:39 PM, <d...@veryhaha.com> wrote: > var s uint = 33 > var u2 = float64(1>>s) // illegal: 1 has type float64, cannot shift > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.