Skip to content

Commit 6195c28

Browse files
authored
Merge pull request #21756 from JuliaLang/teh/linspace_promotion
Fix a promotion failure with linspace
2 parents ab29eb3 + 15fd965 commit 6195c28

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

base/range.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ julia> linspace(1.3,2.9,9)
238238
```
239239
"""
240240
linspace(start, stop, len::Real=50) = linspace(promote_noncircular(start, stop)..., Int(len))
241+
linspace(start::T, stop::T, len::Real=50) where {T} = linspace(start, stop, Int(len))
241242

242243
linspace(start::Real, stop::Real, len::Integer) = linspace(promote(start, stop)..., len)
243244
linspace(start::T, stop::T, len::Integer) where {T<:Integer} = linspace(Float64, start, stop, len, 1)

test/ranges.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ L64 = @inferred(linspace(Int64(1), Int64(4), 4))
2525
@test L32[2] == 2 && L64[2] == 2
2626
@test L32[3] == 3 && L64[3] == 3
2727
@test L32[4] == 4 && L64[4] == 4
28+
@test @inferred(linspace(1.0, 2.0, 2.0f0)) === linspace(1.0, 2.0, 2)
2829

2930
r = 5:-1:1
3031
@test r[1]==5

0 commit comments

Comments
 (0)