Range has the same behavior. It gives nonsensical enough results for length=0, but errors, rather than defaulting to the valid singleton range 0:0
that I expect.
julia> range(0, stop=2, length=0)
0.0:-2.0:2.0
julia> range(0, stop=2, length=1)
ERROR: ArgumentError: range(0.0, stop=2.0, length=1): endpoints differ
Stacktrace:
[1] _linspace1(#unused#::Type{Float64}, start::Float64, stop::Float64, len::Int64)
@ Base ./twiceprecision.jl:678
[2] _linspace(#unused#::Type{Float64}, start_n::Int64, stop_n::Int64, len::Int64, den::Int64)
@ Base ./twiceprecision.jl:662
[3] _linspace
@ ./twiceprecision.jl:660 [inlined]
[4] _range
@ ./range.jl:441 [inlined]
[5] #range#57
@ ./range.jl:91 [inlined]
[6] top-level scope
@ REPL[2]:1
julia> range(0, stop=2, length=2)
0.0:2.0:2.0