Skip to content

cmd/compile: duplicate error for invalid complex number const conversion #33921

Closed

Description

@pestophagous

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

Activity

  1. added this to the Unplanned milestone on Aug 29, 2019
  2. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Aug 29, 2019
  3. gopherbot commented on Oct 16, 2019

    @gopherbot
    Contributor

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

  4. cuonglm commented on Aug 14, 2022

    @cuonglm
    Member

    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
    
  5. locked and limited conversation to collaborators on Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions