diff --git a/src/extensions.jl b/src/extensions.jl index 9a43dc5..72dcca1 100644 --- a/src/extensions.jl +++ b/src/extensions.jl @@ -59,8 +59,13 @@ tags[:unionall] = d -> UnionAll(d[:var], d[:body]) lower(x::Vector{Any}) = copy(x) lower(x::Vector{UInt8}) = x -reinterpret_(::Type{T}, x) where T = - T[reinterpret(T, x)...] +function reinterpret_(::Type{T}, x) where T + len = Int(length(x) * (sizeof(eltype(x)) / sizeof(T))) + GC.@preserve x begin + return unsafe_wrap(Array, Ptr{T}(pointer(x)), len) + end +end + function lower(x::Array) ndims(x) == 1 && !isbitstype(eltype(x)) && return Any[x...]