Skip to content

Commit 1d56eaa

Browse files
committed
axistype should create OneTo for better similar support
1 parent b2889ed commit 1d56eaa

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/ranges.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ end
187187
end
188188
end
189189

190+
Base.Broadcast.axistype(r::OptionallyStaticUnitRange{StaticInt{1}}) = Base.OneTo(last(r))
191+
190192
"""
191193
SUnitRange(start::Int, stop::Int)
192194

test/ranges.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
@test @inferred(eachindex(static(-7):static(7))) === static(1):static(15)
119119
@test @inferred((static(-7):static(7))[first(eachindex(static(-7):static(7)))]) == -7
120120

121-
@test @inferred(firstindex(128:static(-1):1)) == 1
121+
@test @inferred(firstindex(128:static(-1):1)) == 1
122+
123+
@test similar(Matrix{Int}(undef, 2, 3), (static(1):4, Base.OneTo(5))) isa Matrix{Int}
122124
end
123125

0 commit comments

Comments
 (0)