Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: real/imag builtins mishandle untyped arguments #14424

Closed
mdempsky opened this issue Feb 20, 2016 · 1 comment
Closed

cmd/compile: real/imag builtins mishandle untyped arguments #14424

mdempsky opened this issue Feb 20, 2016 · 1 comment
Milestone

Comments

@mdempsky
Copy link
Member

Go spec says:

For real and imag, the argument must be of complex type, and the return type is the corresponding floating-point type: float32 for a complex64 argument, and float64 for a complex128 argument. If the argument evaluates to an untyped constant, it must be a number, and the return value of the function is an untyped floating-point constant.

$ cat /tmp/cplx.go
package cplx

const (
        a int = real(0i)
        b = imag(0)
)
$ go tool compile /tmp/cplx.go
/tmp/cplx.go:4: cannot use real(0i) (type float64) as type int in const initializer
/tmp/cplx.go:5: invalid argument 0 (type int) for imag
$ gccgo-4.8 -c /tmp/cplx.go
$ gotype /tmp/cplx.go
@bradfitz bradfitz added this to the Go1.7 milestone Feb 20, 2016
@griesemer
Copy link
Contributor

Duplicate of #11945. Closing.

@golang golang locked and limited conversation to collaborators Feb 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants