-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Description
What version of Go are you using (go version
)?
go1.7.3 darwin/amd64
What operating system and processor architecture are you using (go env
)?
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/simen/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.7.3/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.7.3/libexec/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_9/2x43ffkj2t13pf5wn5fwnwtc0000gn/T/go-build537154098=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
What did you do?
https://play.golang.org/p/5dRCQ7TYEB
package main
import "fmt"
func main() {
nil := "World"
true := false
if (true == false) {
fmt.Printf("Hello, %s!", nil)
}
}
What did you expect to see?
Expected the code not to compile because it assigns arbitrary values to (what I expected to be) important reserved words.
What did you see instead?
The code works as … unexpected and prints "Hello, World"
.
I understand these have status as Predeclared identifiers (https://golang.org/ref/spec#Predeclared_identifiers) but question the value of not flagging these as errors immediately.
Metadata
Metadata
Assignees
Labels
No labels