Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

'invalid recursive type' error (may be 582 again?) #667

Closed
gopherbot opened this Issue Mar 15, 2010 · 11 comments

Comments

Projects
None yet
3 participants

by ajb44.geo:

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
Contributor

rsc commented Mar 25, 2010

Comment 1:

Are you sure you have an up-to-date compiler?
; cat >x.go
package gtk
type _Cstruct__GList struct {
    next    *_C_GList
    prev    *_C_GList
}
; 6g x.go
x.go:5: undefined: _C_GList
; 8g x.go
x.go:5: undefined: _C_GList
;

Owner changed to r...@golang.org.

Status changed to WaitingForReply.

Comment 2 by ajb44.geo:

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.

Comment 3 by ajb44.geo:

Just in case, I did a hg pull;hg update. it still fails on '6c356775e908 tip'.
Contributor

rsc commented Mar 26, 2010

Comment 4:

Status changed to Accepted.

Contributor

rsc commented May 5, 2010

Comment 5:

Labels changed: added priority-high, removed priority-medium.

Contributor

rsc commented Sep 11, 2010

Comment 6:

Labels changed: added compilerbug.

Comment 7 by lstoakes:

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 *that
type* is referenced in 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

Comment 8 by lstoakes:

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

Comment 9 by lstoakes:

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
Contributor

robpike commented Apr 7, 2011

Comment 10:

Issue #1672 has been merged into this issue.

Contributor

rsc commented Apr 28, 2011

Comment 11:

This issue was closed by revision b6f0632.

Status changed to Fixed.

@rsc rsc was assigned by gopherbot Apr 28, 2011

@gopherbot gopherbot 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.