Comments

What steps will reproduce the problem?
1. cat <<END >min.go
// Created by cgo - DO NOT EDIT
package gtk
type _Cstruct__GList struct {
next *_C_GList
prev *_C_GList
}
END
2. 6g min.go
What is the expected output? What do you see instead?
Expect nothing, see:
min.go:8: invalid recursive type _C_GList
What is your $GOOS? $GOARCH?
GOOS=linux
GOARCH=amd64
Which revision are you using? (hg identify)
be3bb466cbd1+ tip
Please provide any additional information below.
This bug found by attempting to do 'make example'
in go-gtk version e9a198116f1fe92a9b27e09059cc566f5c4d453a

This comment has been minimized.

Oops, I had missed the last line of the test file when copying. Should be:
; cat <<END >x.go
// Created by cgo - DO NOT EDIT
package gtk
type _Cstruct__GList struct {
next *_C_GList
prev *_C_GList
}
type _C_GList _Cstruct__GList
END
I've run all.bash again and it definiteley fails on that version of the compiler ,
which was up to date as of when I submitted.

This comment has been minimized.

irstly - I've submitted a (working) patch for this. Yay! Though it probably needs some
work to clean up the code.
Secondly - I think it's clearer to look at the more general perspective of the problem -
it arises when you declare a type literal which copies the contents of a type in which
itself is referenced to via a pointer. Ok, probably clearer via examples. The simplest:-
type Foo struct {
next *Bar
}
type Bar Foo
Which raises the compiler error 'invalid recursive type Bar'
Now, (prior to the patch), if you actually declared this as follows:-
type Bar Foo
type Foo struct {
next *Bar
}
It would compile fine.
We can actually extend this to a couple of other cases which cause further trouble when
trying to fix this problem:-
type Foo struct {
next *Bar
}
type Bar Baz
type Baz Blah
type Blah Foo
And something like this:-
type Foo struct {
next struct {
x *struct {
y *****struct {
z struct {
argh Bar
}
}
}
}
}
type Bar Foo

This comment has been minimized.

Firstly - I've submitted a (working) patch for this. Yay! Though it probably needs some
work to clean up the code.
Secondly - I think it's clearer to look at the more general perspective of the problem -
it arises when you declare a type literal which copies the contents of a type in which
itself is referenced to via a pointer. Ok, probably clearer via examples. The simplest:-
type Foo struct {
next *Bar
}
type Bar Foo
Which raises the compiler error 'invalid recursive type Bar'
Now, (prior to the patch), if you actually declared this as follows:-
type Bar Foo
type Foo struct {
next *Bar
}
It would compile fine.
We can actually extend this to a couple of other cases which cause further trouble when
trying to fix this problem:-
type Foo struct {
next *Bar
}
type Bar Baz
type Baz Blah
type Blah Foo
And something like this:-
type Foo struct {
next struct {
x *struct {
y *****struct {
z struct {
argh Bar
}
}
}
}
}
type Bar Foo