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

Redefining recursive type fails #21816

Closed
cstjean opened this issue May 12, 2017 · 7 comments
Closed

Redefining recursive type fails #21816

cstjean opened this issue May 12, 2017 · 7 comments
Assignees

Comments

@cstjean
Copy link
Contributor

cstjean commented May 12, 2017

Redefining non-parametric, recursive types fails:

struct Trace
    traces::Vector{Trace}
end
struct Trace
    traces::Vector{Trace}
end
> invalid redefinition of constant Trace
@andyferris
Copy link
Member

Seems genuinely ambiguous which Trace is referred to in the body of the redefinition - but I guess if we want to support this then the recursive form needs to be assumed.

@StefanKarpinski
Copy link
Member

I don't think it's actually ambiguous since only one thing can have the name Trace at the end of the day, and the "redefinition" can't actually change the identity of that thing.

@yashbha
Copy link

yashbha commented Aug 28, 2018

What is the solution for this one?

@StefanKarpinski
Copy link
Member

You can wrap the definition in a module and reload the module, which lets you do this. Redefining a recursive definition in the same module does not yet work.

@michaelkyu
Copy link

I'd like to throw in my support for this issue. Being able to redefine structs without getting this error would be useful in Jupyter notebooks, where a user is often prototyping code and changing definitions. I am running into this issue myself.

@StefanKarpinski
Copy link
Member

It would certainly be nice—I don't think there's any opposition. It's just a low priority annoyance that no one has had time or sufficient motivation to work on. If anyone wants to try, they're welcome to!

@StefanKarpinski StefanKarpinski added help wanted Indicates that a maintainer wants help on an issue or pull request parser Language parsing and surface syntax labels Jan 8, 2019
@pedroborgesmelo
Copy link

Need this here.

@JeffBezanson JeffBezanson removed help wanted Indicates that a maintainer wants help on an issue or pull request parser Language parsing and surface syntax labels Jun 3, 2020
@JeffBezanson JeffBezanson self-assigned this Jun 3, 2020
KristofferC pushed a commit that referenced this issue Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants