Skip to content

Commit

Permalink
Make Colon immutable. Fixes 18034.
Browse files Browse the repository at this point in the history
(cherry picked from commit 06b171d)
ref #18036
  • Loading branch information
tkoolen authored and tkelman committed Aug 20, 2016
1 parent 1d566a9 commit 20673d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function isassigned(v::SimpleVector, i::Int)
end

# index colon
type Colon
immutable Colon
end
const (:) = Colon()

Expand Down
12 changes: 12 additions & 0 deletions test/subarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,15 @@ u = (1,2:3)
let size=(x,y)-> error("should not happen")
@test X[1:end,2,2] == @view X[1:end,2,2]
end

# issue #18034
# ensure that it is possible to create an isbits, LinearFast view of an immutable Array
let
immutable ImmutableTestArray{T, N} <: Base.DenseArray{T, N}
end
Base.size(::Union{ImmutableTestArray, Type{ImmutableTestArray}}) = (0, 0)
Base.linearindexing(::Union{ImmutableTestArray, Type{ImmutableTestArray}}) = Base.LinearFast()
a = ImmutableTestArray{Float64, 2}()
@test Base.linearindexing(view(a, :, :)) == Base.LinearFast()
@test isbits(view(a, :, :))
end

0 comments on commit 20673d9

Please sign in to comment.