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: double error trying to convert bool to int #23075

Closed
andwj opened this issue Dec 10, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@andwj
Copy link

commented Dec 10, 2017

What did you do?

Tried to convert a bool to an int.
For example: x := int(false)
https://play.golang.org/p/5eGVyWi1kH

What did you expect to see?

a single error message

What did you see instead?

two slightly different error messages for the same source location

main.go:4:9: cannot convert false to type int
main.go:4:9: cannot convert false (type bool) to type int

System details

go version go1.9.2 linux/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/gouser/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build143268145=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOROOT/bin/go version: go version go1.9.2 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.9.2
uname -sr: Linux 4.9.0-4-amd64
Distributor ID:	Debian
Description:	Debian GNU/Linux 9.2 (stretch)
Release:	9.2
Codename:	stretch
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Debian GLIBC 2.24-11+deb9u1) stable release version 2.24, by Roland McGrath et al.
gdb --version: GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
@namusyaka

This comment has been minimized.

Copy link
Member

commented Dec 10, 2017

I guess the issue has been fixed by d05a123.
See #20812.

Acutally, the issue cannot be reproduced in my local, its output now is:

main.go:4:9: cannot convert false (type untyped bool) to type int`

My go version is go version devel +25363de Fri Dec 8 16:54:20 2017 +0000 darwin/amd64.

@mvdan

This comment has been minimized.

Copy link
Member

commented Dec 10, 2017

Was about to write the same - cannot reproduce on tip either. Seems like a duplicate indeed.

@mvdan mvdan closed this Dec 10, 2017

@andwj

This comment has been minimized.

Copy link
Author

commented Dec 11, 2017

Yeah, I searched for issues about bools and "double error" but I did not search for "duplicate error"

Thanks.

@mikioh mikioh changed the title double error trying to convert bool to int cmd/compile: double error trying to convert bool to int Jan 5, 2018

@golang golang locked and limited conversation to collaborators Jan 5, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.