Skip to content

cmd/compile: double error when break is not in a loop #51456

@alicebob

Description

@alicebob

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

go version devel go1.19-d3fe4e193e Thu Mar 3 16:02:44 2022 +0000 linux/amd64

and

go version go1.18rc1 linux/amd64

Does this issue reproduce with the latest release?

(edit) No, on 1.17.7 it's a single error.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/harmen/.cache/go-build"
GOENV="/home/harmen/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/harmen/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/harmen/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/harmen/src/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/harmen/src/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.19-d3fe4e193e Thu Mar 3 16:02:44 2022 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
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-build2287321463=/tmp/go-build -gno-record-gcc-switches"

What did you do?

package main

func main() {
	break
}

https://go.dev/play/p/pyIH7X9EZMT?v=gotip

What did you expect to see?

A single error

What did you see instead?

harmen@umount:/tmp$ go run foo.go
# command-line-arguments
./foo.go:4:2: break is not in a loop, switch, or select
./foo.go:4:2: break is not in a loop, switch, or select statement
harmen@umount:/tmp$ 

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions