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

go/types: rejects valid program #7158

Closed
dominikh opened this issue Jan 21, 2014 · 6 comments
Closed

go/types: rejects valid program #7158

dominikh opened this issue Jan 21, 2014 · 6 comments
Assignees
Milestone

Comments

@dominikh
Copy link
Member

@dominikh dominikh commented Jan 21, 2014

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. http://play.golang.org/p/qMndFaeqVe
2.
3.

What is the expected output?
Should type check without error

What do you see instead?
./foo.go:4:9: cannot initialize variable  (type main.Node) with wrapElement() (value of
type main.Element)

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?


Which version are you using?  (run 'go version')
go version go1.2 linux/amd64

Please provide any additional information below.
@griesemer
Copy link
Contributor

@griesemer griesemer commented Feb 12, 2014

Comment 1:

Labels changed: added release-go1.3, repo-tools.

Owner changed to @griesemer.

Status changed to Accepted.

Loading

@griesemer
Copy link
Contributor

@griesemer griesemer commented Feb 12, 2014

Comment 2:

Slightly simplified test case:
package p
var x1 T1 = T3(nil)
type T1 interface {
    // Note that embedding T2 in T1 causes the problem. If
    // we remove T2 and add m2() T4 to T1
    // directly, it compiles fine.
    T2
}
type T2 interface {
    m2() T4
}
type T3 interface {
    T1
}
type T4 interface {
    m4() T3
}

Loading

@griesemer
Copy link
Contributor

@griesemer griesemer commented Feb 12, 2014

Comment 3:

shorter:
package p
var x1 T1 = T4(nil)
type T1 interface {
    T2
}
type T2 interface {
    m() T4
}
type T4 interface {
    T1
}

Loading

@griesemer
Copy link
Contributor

@griesemer griesemer commented Mar 31, 2014

Comment 4:

The problem lies in checker.interfaceType which incorrectly makes assumptions about an
incomplete interface type. The solution may require a separate pass to determine type
dependencies first (TBD).
Work-around (not acceptable in general):
package p
type _ T4
var x1 T1 = T4(nil)
type T1 interface {
    T2
}
type T2 interface {
    m() T4
}
type T4 interface {
    T1
}

Loading

@griesemer
Copy link
Contributor

@griesemer griesemer commented Apr 2, 2014

Comment 5:

Pending CL: https://golang.org/cl/83640043

Status changed to Started.

Loading

@griesemer
Copy link
Contributor

@griesemer griesemer commented Apr 2, 2014

Comment 6:

This issue was closed by revision golang/tools@0b23073.

Status changed to Fixed.

Loading

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@rsc rsc removed the release-go1.3 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants