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

Closed
aarzilli opened this issue Apr 26, 2018 · 5 comments
Closed

cmd/compile: can not use statictmp_0 as variable name #25113

aarzilli opened this issue Apr 26, 2018 · 5 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@aarzilli
Copy link
Contributor

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
Copy link
Contributor

Also fails with Go 1.7 and 1.9.

@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 26, 2018
@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Apr 26, 2018
@josharian
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor Author

@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
Copy link

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

@bradfitz bradfitz modified the milestones: Unplanned, Go1.13 Jan 14, 2019
@golang golang locked and limited conversation to collaborators Feb 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants