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/gc: unnamed structs with embedded fields are nuked on import #5910

Closed
davecheney opened this issue Jul 18, 2013 · 6 comments
Closed

cmd/gc: unnamed structs with embedded fields are nuked on import #5910

davecheney opened this issue Jul 18, 2013 · 6 comments
Milestone

Comments

@davecheney
Copy link
Contributor

What steps will reproduce the problem?

lucky(~/src) % cat q/q.go
package q

type Package struct { 
        name string 
}

type Future struct {
        result chan struct {
                *Package
                error
        }
}

func (t *Future) Result() (*Package, error) {
        result := <-t.result
        t.result <- result
        return result.Package, result.error
}

lucky(~/src) % cat q.go 
package main

import "q"

func main() {
        f := new(q.Future)
        f.Result()
}
lucky(~/src) % go build q.go

What is the expected output? What do you see instead?

Want: compilation

Got: # command-line-arguments
./q.go:3: cannot use <-q.t·3.result (type struct { *q.Package; error }) as type
struct {} in assignment
./q.go:3: cannot use q.result·4 (type struct {}) as type struct { *q.Package; error }
in send
./q.go:3: q.result·4.Package undefined (type struct {} has no field or method Package)
./q.go:3: q.result·4.error undefined (type struct {} has no field or method q.error)
./q.go:7: cannot use q.result·4 (type struct {}) as type struct { *q.Package; error }
in function argument
./q.go:7: tempname called with nil type

Rémy suggested there were two issues

* unnamed structs with embedded fields are nuked on import.
* structs with embedded builtins in inlined bodies are buggy like in issue #3552
(although embedded builtins received endless fixes).

Please use labels and text to provide additional information.

See also discussion: https://groups.google.com/d/msg/golang-dev/kK28QLd8jXA/f0deO0VKmW0J
@dsymonds
Copy link
Contributor

Comment 2:

Labels changed: added priority-soon, removed priority-triage.

@remyoudompheng
Copy link
Contributor

Comment 3:

Updated by revision 56696c13acef (fixing the case of non-builtin embedded fields).

@remyoudompheng
Copy link
Contributor

Comment 4:

Issue #6153 has been merged into this issue.

@remyoudompheng
Copy link
Contributor

Comment 5:

Issue #6257 has been merged into this issue.

@remyoudompheng
Copy link
Contributor

Comment 6:

This issue was closed by revision a85cfbd.

Status changed to Fixed.

@ianlancetaylor
Copy link
Contributor

Comment 7:

Issue #6773 has been merged into this issue.

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

6 participants