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

Boolean literal are allowed to be used as variable names #36627

Closed
raghavshrma opened this issue Jan 17, 2020 · 3 comments
Closed

Boolean literal are allowed to be used as variable names #36627

raghavshrma opened this issue Jan 17, 2020 · 3 comments

Comments

@raghavshrma
Copy link

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

$ go version
go version go1.13.6 linux/amd64

Does this issue reproduce with the latest release?

Not sure

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/raghav/.cache/go-build"
GOENV="/home/raghav/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/raghav/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build172516599=/tmp/go-build -gno-record-gcc-switches"

What did you do?

package main

import "fmt"

var true = false

func main() {
	if true == false {
		fmt.Println("foo!!")
	}

	if true {
		fmt.Println("bar!!")
	}
}

What did you expect to see?

Compilation Error

What did you see instead?

Output:

foo!!
@raghavshrma
Copy link
Author

I'm completely new to Golang and was just trying the pattern matching support in this language, but accidentally ended up with this.
So I don't even know that whether this is a bug or intentional behaviour, and in case it is then what is the use case.

@ghost
Copy link

ghost commented Jan 17, 2020

Not an issue. See #18193.

@ALTree
Copy link
Member

ALTree commented Jan 17, 2020

As @bontibon said, this is working as intended. Closing here.

@ALTree ALTree closed this as completed Jan 17, 2020
@golang golang locked and limited conversation to collaborators Jan 16, 2021
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

3 participants