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

Ref(Ref(x)) gives wrong type #26271

Closed
tk3369 opened this issue Mar 1, 2018 · 4 comments
Closed

Ref(Ref(x)) gives wrong type #26271

tk3369 opened this issue Mar 1, 2018 · 4 comments

Comments

@tk3369
Copy link
Contributor

tk3369 commented Mar 1, 2018

From Slack:

julia> mutable struct Foo end

julia> r = Ref{Foo}()
Base.RefValue{Foo}(#undef)

julia> typeof(r)
Base.RefValue{Foo}

julia> typeof(Ref(r))
Base.RefValue{Foo}
@vtjnash
Copy link
Sponsor Member

vtjnash commented Mar 1, 2018

Will be fixed on master?

┌ Warning: `Ref(x::Ref)` is deprecated, use `x` instead.
│   caller = top-level scope

@tk3369
Copy link
Contributor Author

tk3369 commented Mar 1, 2018

BTW, I was reporting the issue against 0.6. Is the behavior going to be changed for 0.7?

@JeffBezanson
Copy link
Sponsor Member

Certainly convert(Ref, x::Ref) has to return x, but I don't see why Ref(Ref(x)) can't make a ref of a ref. RefValue supports this, for example.

@martinholters
Copy link
Member

Ref. #21527. The plan is to make Ref(Ref(x)) return a Ref{<:Ref}, namely a RefValue{RefValue{typeof(x)}}. In 0.7, the old behavior will be deprecated (as already is on master). Meanwhile, Ref{typeof(r)}(r) can be use to get the desired result on 0.6 and 0.7.

@vtjnash vtjnash closed this as completed May 5, 2018
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

4 participants