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

8g: seg fault struct with func to interface #410

Closed
stevenblenkinsop opened this issue Dec 11, 2009 · 3 comments
Closed

8g: seg fault struct with func to interface #410

stevenblenkinsop opened this issue Dec 11, 2009 · 3 comments

Comments

@stevenblenkinsop
Copy link

What steps will reproduce the problem?
1. file: "main.go" :

package main
import "fmt";

type doer interface { do(); }
type Doer struct { do func(); }

func main()
{
  d := Doer{ func(){ fmt.Println("Done"); } };
  _ = doer(d);
}

2. compile with command: $ 8g main.go

What is the expected output? What do you see instead?
compile fails with output "Segmentation fault"

expected: either conversion is valid or isn't (preferably is ;) )

What is your $GOOS?  $GOARCH?
$GOOS : linux
$GOARCH : 386

Which revision are you using?  (hg identify)
4d7f5eddd695 tip
(was also present in release)

Please provide any additional information below.
For:
var d struct { do func(); };
d.do = func(){
  fmt.Println("Done");
};  
_ = doer(d);

compiler returns: 
"struct { do func() } is not doer
        missing do()"

Attachments:

  1. main.go (216 bytes)
  2. main1.go (238 bytes)
@stevenblenkinsop
Copy link
Author

Comment 1:

Shoot, name should be "Segmentation Fault: Converting struct with closure to matching
interface"

@rsc
Copy link
Contributor

rsc commented Dec 11, 2009

Comment 2:

Thanks.  The crash is a bug but the error in the
alternate program is correct: having a field and
having a method are two different things.

Labels changed: added compilerbug.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Dec 16, 2009

Comment 3:

This issue was closed by revision 5d754bf.

Status changed to Fixed.

Merged into issue #-.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants