Skip to content

Commit 58ed793

Browse files
authored
Fix typo in unsafe_wrap method (#54582)
1 parent a1e1a3a commit 58ed793

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

base/pointer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ end
118118
function unsafe_wrap(::Union{Type{GenericMemory{kind,<:Any,Core.CPU}},Type{GenericMemory{kind,T,Core.CPU}}},
119119
p::Ptr{T}, dims::Tuple{Int}; own::Bool = false) where {kind,T}
120120
ccall(:jl_ptr_to_genericmemory, Ref{GenericMemory{kind,T,Core.CPU}},
121-
(Any, Ptr{Cvoid}, Csize_t, Cint), GenericMemory{kind,T,Core.CPU}, p, dim[1], own)
121+
(Any, Ptr{Cvoid}, Csize_t, Cint), GenericMemory{kind,T,Core.CPU}, p, dims[1], own)
122122
end
123123
function unsafe_wrap(::Union{Type{GenericMemory{kind,<:Any,Core.CPU}},Type{GenericMemory{kind,T,Core.CPU}}},
124124
p::Ptr{T}, d::Integer; own::Bool = false) where {kind,T}

test/core.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6251,6 +6251,16 @@ let
62516251
@test_throws ArgumentError unsafe_wrap(Array, convert(Ptr{Union{Int, Nothing}}, pointer(A5)), 6)
62526252
end
62536253

6254+
# More unsafe_wrap
6255+
let
6256+
a = [1, 2, 3]
6257+
GC.@preserve a begin
6258+
m = unsafe_wrap(Memory{Int}, pointer(a), (3,))
6259+
@test m == a
6260+
@test m isa Memory{Int}
6261+
end
6262+
end
6263+
62546264
# copyto!
62556265
A23567 = Vector{Union{Float64, Nothing}}(undef, 5)
62566266
B23567 = collect(Union{Float64, Nothing}, 1.0:3.0)

0 commit comments

Comments
 (0)