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: non-defined struct types with the same field set and order should be viewed as identical types. #23074

go101 opened this issue Dec 10, 2017 · 2 comments


None yet
2 participants
Copy link

commented Dec 10, 2017

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

go version go1.9.2 linux/amd6

Does this issue reproduce with the latest release?

Yes. This is broken since go 1.8.

What did you do?

package m:

package m

func FFF(i interface{}) {
  _ = i.(struct {a int})

package main:

package main

import "m"

func main() {
  m.FFF(struct {a int}{})

What did you expect to see?

Not panic

What did you see instead?



This comment has been minimized.

Copy link

commented Dec 10, 2017

If the a field becomes exported. Then it is not panic. But the rule of unexported fields from different packages are always viewed as fields with different names is only for defined struct types.


This comment has been minimized.

Copy link

commented Dec 10, 2017

Aha, looks the rule also applies for non-defined struct types. That is a good news.
So this is a bug of 1.7-. 1.7- compilers don't panic the program but they should.

@go101 go101 closed this Dec 10, 2017

@golang golang locked and limited conversation to collaborators Dec 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.