Skip to content

cmd/compile: inconsistent error message when identifier begins with invalid character #42114

@smasher164

Description

@smasher164

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

go version go1.15.2 darwin/amd64

What did you do?

I tried to compile the following program: https://play.golang.org/p/379msfdOuwi

package main

func main() {
	var 3x = 3
	3x := 3  
	var $x = 3
	$x := 3
}

What did you expect to see?

./prog.go:4:6: syntax error: unexpected literal 3, expecting name
./prog.go:5:3: syntax error: unexpected literal 3, expecting name
./prog.go:6:6: invalid character U+0024 '$'
./prog.go:7:2: invalid character U+0024 '$'

What did you see instead?

./prog.go:4:6: syntax error: unexpected literal 3, expecting name
./prog.go:5:3: syntax error: unexpected x at end of statement
./prog.go:6:6: invalid character U+0024 '$'
./prog.go:7:2: invalid character U+0024 '$'
./prog.go:7:5: no new variables on left side of :=

Metadata

Metadata

Assignees

Labels

NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions