Small correction to the overloaded deepcopy. Seems that the right way to
overload deepcopy is to overload deepcopy_internal, and not deepcopy
itself. Thus the added function should be,
Base.deepcopy_internal{T}(x::Nullable{T}, dict::ObjectIdDict) = isnull(x) ?
Nullable{T}() : Base.deepcopy_internal(x, dict)
Uri
On Sunday, November 29, 2015 at 8:05:28 PM UTC+2, Uri Patish wrote:
>
> Hi,
>
> I came across the following issue. If I instantiate a Nullable{T} where T
> is an abstract type, and then try call deepcopy on it, I get UndefRefError.
> For example,
>
> julia> a = Nullable{Real}()
> Nullable{Real}()
>
> julia> b = deepcopy(a)
> ERROR: UndefRefError: access to undefined reference
> in _deepcopy_t at deepcopy.jl:43
> in deepcopy_internal at deepcopy.jl:28
> in deepcopy at deepcopy.jl:8
>
> This doesn't happen when T isn't abstract, e.g.,
>
> julia> a = Nullable{Float64}()
> Nullable{Float64}()
>
> julia> b = deepcopy(a)
> Nullable{Float64}()
>
> works just fine. This can be remedied by overloading deepcopy for Nullable
> types,
>
> Base.deepcopy{T}(x::Nullable{T}) = isnull(x) ? Nullable{T}() : deepcopy(x)
>
> but was wondering if I'm missing something or maybe this is bug and the
> the former function should be added to Base.
>
> I'm working on version 0.4.0.
>
> Uri
>
>
>