Navigation Menu

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: imag(0) is valid but not accepted #17446

Closed
griesemer opened this issue Oct 14, 2016 · 5 comments
Closed

cmd/compile: imag(0) is valid but not accepted #17446

griesemer opened this issue Oct 14, 2016 · 5 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@griesemer
Copy link
Contributor

package p
var _ = imag(0)

doesn't compile:

$ go tool compile y.go
y.go:2: invalid argument 0 (type int) for imag

But it's clearly accepted by the spec ("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."). Both gotype and gccgo accept it.

@griesemer griesemer added this to the Go1.8 milestone Oct 14, 2016
@griesemer
Copy link
Contributor Author

See also #17398 (indirectly related).

@griesemer griesemer self-assigned this Oct 14, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 17, 2016
@rsc rsc modified the milestones: Go1.9, Go1.8 Oct 21, 2016
@odeke-em
Copy link
Member

I think when we fix this issue, we should also pay attention to #11945 because fixing that mentioned issue will mean that
imag(0) will return an untyped value instead of a floating point constant not as the spec is quoted in #17446 (comment)

But it's clearly accepted by the spec ("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."). Both gotype 
and gccgo accept it.

@josharian
Copy link
Contributor

When we test this, make sure to test real too: const x = real(0). (go-fuzz just re-found this bug.)

@gopherbot
Copy link

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

gopherbot pushed a commit that referenced this issue Jun 7, 2017
Prep work for issues mentioned below. No semantic or functionality change.

For #11945.
For #17446.

Change-Id: Ia1bb2b87647a6daa47f7863c0eb42cf5e1d35a7c
Reviewed-on: https://go-review.googlesource.com/45076
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Jun 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants