Skip to content

Commit 9136dca

Browse files
authored
Fix behavior of copy and similar (#12)
1 parent cf3928d commit 9136dca

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/ReadOnlyArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Base.iterate(x::ReadOnlyArray, args...) = iterate(x.parent, args...)
6969

7070
Base.length(x::ReadOnlyArray) = length(x.parent)
7171

72-
Base.similar(x::ReadOnlyArray) = similar(x.parent) |> ReadOnlyArray
72+
Base.similar(x::ReadOnlyArray) = similar(x.parent)
7373

7474
Base.axes(x::ReadOnlyArray) = axes(x.parent)
7575

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ end
5151
fa = f()
5252
@test fa isa ReadOnlyArray{Float64,2}
5353
@test fa == x
54+
55+
a = ReadOnly([1, 2])
56+
@test typeof(similar(a)) === Vector{Int64}
57+
58+
@test copy(a) == [1, 2]
59+
@test typeof(copy(a)) === Vector{Int64}
5460
end
5561
end
5662

0 commit comments

Comments
 (0)