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: duplicate error for invalid complex number const conversion #33921

Closed
pestophagous opened this issue Aug 29, 2019 · 2 comments
Closed
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@pestophagous
Copy link
Contributor

What version of Go are you using (go version)?

tip of master on gerrit.

$ go version
go version devel +d0eaec7 Wed Aug 28 21:48:01 2019 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/someone/.cache/go-build"
GOENV="/home/someone/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/someone/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/repos/go_002/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/repos/go_002/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build522812886=/tmp/go-build -gno-record-gcc-switches"

What did you do?

package main

func main() {
	_ = uint(-4 + 2i)
}

https://play.golang.org/p/hIqU2ydLGdn

What did you expect to see?

A single error like "cannot convert complex to uint".

What did you see instead?

Two errors:

./prog.go:4:10: constant (-4+2i) truncated to integer
./prog.go:4:10: constant -4 overflows uint
@ALTree ALTree added this to the Unplanned milestone Aug 29, 2019
@ALTree ALTree added the NeedsFix The path to resolution is known, but the work has not been done. label Aug 29, 2019
@gopherbot
Copy link

Change https://golang.org/cl/201208 mentions this issue: cmd/compile: report single error for invalid complex const conversions

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
@cuonglm
Copy link
Member

cuonglm commented Aug 14, 2022

Since go1.18 with new typechecker, there's only 1 error reported:

$ go1.18.5 tool compile r.go 
r.go:4:11: cannot convert -4 + 2i (untyped complex constant (-4 + 2i)) to type uint

@cuonglm cuonglm closed this as completed Aug 14, 2022
@golang golang locked and limited conversation to collaborators Aug 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants