Skip to content

Commit 5149835

Browse files
committed
Fix string parsing with //
1 parent 99c27c0 commit 5149835

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/intervals/construction.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ if not, a warning is printed and the empty interval is returned.
9999
"""
100100
function interval(::Type{T}, a, b) where {T<:NumTypes}
101101
is_valid_interval(a, b) && return Interval{T}(a, b)
102-
@warn "Invalid input, empty interval is returned"
102+
@warn "invalid input, empty interval is returned"
103103
return emptyinterval(T)
104104
end
105105
interval(a::T, b::S) where {T, S} = interval(promote_numtype(T, S), a, b)

src/parsing.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ julia> parse(Interval{Float64}, "foobar")
123123
124124
```
125125
"""
126-
function parse(::Type{Interval{T}}, s::AbstractString) where {T<:NumTypes}
126+
function parse(::Type{F}, s::AbstractString) where {F<:Interval}
127127
s = lowercase(strip(s))
128128
try
129-
ival, _ = _parse(Interval{T}, s)
129+
ival, _ = _parse(F, s)
130130
return ival
131131
catch e
132132
if e isa ArgumentError
133-
@warn "invalid input, empty interval returned"
134-
return emptyinterval(T)
133+
@warn "invalid input, empty interval is returned"
134+
return emptyinterval(F)
135135
else
136136
rethrow(e)
137137
end
@@ -234,7 +234,7 @@ Same as `parse(T, s, rounding_mode)`, but also accept string representing ration
234234
"""
235235
function parse_num(T, s, rounding_mode)
236236
if '/' in s
237-
num, denum = parse.(BigInt, split(s, '/'))
237+
num, denum = parse.(BigInt, split(s, '/'; keepempty = false))
238238
return T(num//denum, rounding_mode)
239239
end
240240
return T(parse(BigFloat, s), rounding_mode)

0 commit comments

Comments
 (0)