FAQ
This is expected. Spec:

"If the left operand of a non-constant shift expression is an untyped
constant,
the type of the constant is what it would be if the shift expression were
replaced
by its left operand alone."

var v float32 = 1<<s // illegal: 1 has type float32, cannot shift


On Thursday, July 23, 2015 at 6:14:19 PM UTC+2, zhuxues...@gmail.com wrote:

hi,

I'm testing go1.5beta2, and it reported the following error on:

func main() {
var s uint
s = 2
t := float32(1<<s)
fmt.Println(t)
}

# command-line-arguments
.\hello.go:15: invalid operation: 1 << s (shift of type float32)

But fmt.Println(1<<2) is ok.

If I test this on http://golang.org/, Try go sandbox (go 1.4.2)
Similar error is reported:

# command-line-arguments
/tmp/sandbox544236803/main.go:10: invalid operation: 1 << s (shift of type float32)


I don't know if it is a error, or designed like so.

Thanks.

Le vendredi 17 juillet 2015 12:44:15 UTC+8, Andrew Gerrand a écrit :
Hi Go nuts,

We have just released go1.5beta2, a beta version of Go 1.5.
It is cut from the master branch at the revision tagged go1.5beta2.

Please help us by testing your Go programs with the release, and report
any problems using the issue tracker:
https://golang.org/issue/new

You can download binary and source distributions from the usual place:
https://golang.org/dl/#go1.5beta2

MSI and PKG files are now available for Windows and OS X.
Please try them out.

To find out what has changed in Go 1.5, read the release notes:
https://tip.golang.org/doc/go1.5

Documentation for Go 1.5 is available at:
https://tip.golang.org/

Our hope to release the final version of Go 1.5 in early August.

Andrew
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 13 of 15 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJul 17, '15 at 4:43a
activeJul 27, '15 at 1:19a
posts15
users11
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase