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

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

gopherbot commented Mar 15, 2010

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
@rsc

This comment has been minimized.

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.

@gopherbot

This comment has been minimized.

gopherbot commented Mar 25, 2010

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

This comment has been minimized.

gopherbot commented Mar 25, 2010

Comment 3 by ajb44.geo:

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

This comment has been minimized.

Contributor

rsc commented Mar 26, 2010

Comment 4:

Status changed to Accepted.

@rsc

This comment has been minimized.

Contributor

rsc commented May 5, 2010

Comment 5:

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

@rsc

This comment has been minimized.

Contributor

rsc commented Sep 11, 2010

Comment 6:

Labels changed: added compilerbug.

@gopherbot

This comment has been minimized.

gopherbot commented Mar 31, 2011

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

This comment has been minimized.

gopherbot commented Mar 31, 2011

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

This comment has been minimized.

gopherbot commented Mar 31, 2011

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
@robpike

This comment has been minimized.

Contributor

robpike commented Apr 7, 2011

Comment 10:

Issue #1672 has been merged into this issue.

@rsc

This comment has been minimized.

Contributor

rsc commented Apr 28, 2011

Comment 11:

This issue was closed by revision b6f0632.

Status changed to Fixed.

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