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

Re-evaluating parameterized type definitions erros #16424

Closed
mauro3 opened this issue May 18, 2016 · 9 comments · Fixed by #17618
Closed

Re-evaluating parameterized type definitions erros #16424

mauro3 opened this issue May 18, 2016 · 9 comments · Fixed by #17618
Labels
regression Regression in behavior compared to a previous version types and dispatch Types, subtyping and method dispatch

Comments

@mauro3
Copy link
Contributor

mauro3 commented May 18, 2016

I noticed this inconsistency (both in 0.4 and 0.5):

julia> type B
       a
       end

julia> type B
       a
       end

julia> type A{T}
       a
       end

julia> type A{T}
       a
       end
ERROR: invalid redefinition of constant A

Would be nice if the second would not error.

@KristofferC
Copy link
Member

@mauro3
Copy link
Contributor Author

mauro3 commented May 18, 2016

I thought this must have been discussed somewhere.

@cstjean
Copy link
Contributor

cstjean commented Feb 12, 2017

@vtjnash It seems that this code now fails:

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.0-dev.2778 (2017-02-12 11:20 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 71f6bc9 (0 days old master)
|__/                   |  x86_64-apple-darwin13.4.0

julia> immutable X{T}
          a::T
       end

julia> immutable X{T}
          a::T
       end
ERROR: invalid redefinition of constant X

Is that a regression? It's a bummer for cstjean/ClobberingReload.jl#1 (comment) cc. @rdeits

@KristofferC KristofferC reopened this Feb 12, 2017
@KristofferC KristofferC added regression Regression in behavior compared to a previous version types and dispatch Types, subtyping and method dispatch labels Feb 12, 2017
JeffBezanson added a commit that referenced this issue Feb 13, 2017
fix #16424, allow redefining a type to an equivalent one
@rdeits
Copy link
Contributor

rdeits commented Feb 13, 2017

awesome, thanks @JeffBezanson and @cstjean

@cstjean
Copy link
Contributor

cstjean commented Mar 30, 2017

Some definitions still cannot be reevaluated:

julia> const TupleOf{T} = NTuple{N, T} where {N}
Tuple{Vararg{T,N}} where N where T

julia> const TupleOf{T} = NTuple{N, T} where {N}
ERROR: invalid redefinition of constant TupleOf

@yuyichao
Copy link
Contributor

That's not a type definition.

@cstjean
Copy link
Contributor

cstjean commented Mar 30, 2017

Then parametric type aliases cannot be reevaluated. MWE: MyVector{N} = Vector{N}. Should this be a new issue? I couldn't find anything relevant.

@JeffBezanson
Copy link
Member

We allow re-assigning constants if the new value is identical. We could expand the definition of "identical" for this case.

@cstjean
Copy link
Contributor

cstjean commented Jun 6, 2017

Similar to the type-alias case, this type definition cannot be reevaluated:

struct GG{T<:(Vector{U} where U <: Integer)} end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Regression in behavior compared to a previous version types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants