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: can not use statictmp_0 as variable name #25113

Open
aarzilli opened this Issue Apr 26, 2018 · 5 comments

Comments

Projects
None yet
5 participants
@aarzilli
Contributor

aarzilli commented Apr 26, 2018

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

go version go1.10.1 linux/amd64 and go version devel +5f5168e Thu Apr 26 18:59:07 2018 +0000 linux/amd64

What did you do?

package main

var statictmp_0 string
var a []int

func init() {
	a = []int{ 7 }
}

func main() {
	println(a[0])
}

compiling this produces the error:

./teststatic.go:7:11: statictmp_0 redeclared in this block
	previous declaration at ./teststatic.go:3:5
@ianlancetaylor

This comment has been minimized.

Contributor

ianlancetaylor commented Apr 26, 2018

Also fails with Go 1.7 and 1.9.

@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Apr 26, 2018

@josharian

This comment has been minimized.

Contributor

josharian commented Apr 26, 2018

I know compilers are supposed to implement the spec, but I have admit my first reaction to this is: “Then don’t do that.” Though I think the official way to spell that is: Low priority. :)

@agnivade

This comment has been minimized.

Member

agnivade commented Apr 27, 2018

Wow interesting. A shorter repro -

package main

var statictmp_0 string

// Also fails with these
// type statictmp_0 struct{}
// type statictmp_0 interface{}

func main() {
	a := []int{7}
	println(a)
}

Also fails with structs and interfaces. Are there other reserved keywords like these ?

Maybe good to document them in case this doesn't make it to 1.11.

@aarzilli

This comment has been minimized.

Contributor

aarzilli commented Apr 27, 2018

@josharian: agreed. I only found this while looking at the symbols list in the linker.

@josharian josharian modified the milestones: Go1.11, Unplanned Apr 27, 2018

@gopherbot

This comment has been minimized.

gopherbot commented Oct 16, 2018

Change https://golang.org/cl/142497 mentions this issue: cmd/compile,cmd/link: avoid collisions between statictmps and user vars

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment