Skip to content

cmd/compile: invalid literal causes errors in subsequent lines of valid code #15611

@0xmohit

Description

@0xmohit
$ go version
go version go1.6.2 linux/amd64
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

Tried to compile the following (https://play.golang.org/p/hbj73GGYMU):

$ cat -n t.go 
     1  package main
     2
     3  func main() {
     4          _ = append([]byte("hello "), byte('world')) // invalid
     5          _ = append([]byte("hello "), byte('a'))     // ok
     6  }
     7
$  go tool compile t.go 
t.go:4: missing '
t.go:4: syntax error: unexpected orld, expecting comma or )
t.go:4: missing '
t.go:5: syntax error: unexpected ), expecting }
t.go:6: syntax error: non-declaration statement outside function body

No errors should have been reported for lines 5 and 6. missing ' probably should have been reported just once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions