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: inappropriate suggested token in case of syntax error in "if" statement #47013

Open
gazerro opened this issue Jul 1, 2021 · 2 comments

Comments

@gazerro
Copy link
Contributor

@gazerro gazerro commented Jul 1, 2021

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

$ go version
go version go1.16.5 darwin/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="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/marco/Library/Caches/go-build"
GOENV="/Users/marco/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/marco/go/pkg/mod"
GOOS="darwin"
GOPATH="/Users/marco/go"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/z9/xrln_qks56jbzxjbhs04fpm80000gn/T/go-build771492184=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Compile the following program

package main

func main() {
	if a := true: a { }
}

What did you expect to see?

syntax error: unexpected :, expecting ;

If a SimpleStmt is parsed, and the next token is not a semicolon, I expect the semicolon to be suggested in the error message.

What did you see instead?

syntax error: unexpected :, expecting {
@dmitshur
Copy link
Contributor

@dmitshur dmitshur commented Jul 2, 2021

Thanks for reporting.

Does this also happen in older versions of Go, like 1.14 and before, or is it a more recent regression?

@dmitshur dmitshur added this to the Backlog milestone Jul 2, 2021
@gazerro
Copy link
Contributor Author

@gazerro gazerro commented Jul 2, 2021

Does this also happen in older versions of Go, like 1.14 and before, or is it a more recent regression?

It also happens in older versions, for example in version 1.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants