Skip to content

Commit

Permalink
Improve inference for some regex captures (JuliaLang#41666)
Browse files Browse the repository at this point in the history
* Improve inference for some regex captures

* Switch from typeassert to
  • Loading branch information
jakobnissen authored Jul 22, 2021
1 parent 27c0291 commit f540b9c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion base/irrationals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ big(::Type{<:AbstractIrrational}) = BigFloat
function alignment(io::IO, x::AbstractIrrational)
m = match(r"^(.*?)(=.*)$", sprint(show, x, context=io, sizehint=0))
m === nothing ? (length(sprint(show, x, context=io, sizehint=0)), 0) :
(length(m.captures[1]), length(m.captures[2]))
(length(something(m.captures[1])), length(something(m.captures[2])))
end

# inv
Expand Down
4 changes: 2 additions & 2 deletions base/path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ elseif Sys.iswindows()

function splitdrive(path::String)
m = match(r"^([^\\]+:|\\\\[^\\]+\\[^\\]+|\\\\\?\\UNC\\[^\\]+\\[^\\]+|\\\\\?\\[^\\]+:|)(.*)$"s, path)
String(m.captures[1]), String(m.captures[2])
String(something(m.captures[1])), String(something(m.captures[2]))
end
else
error("path primitives for this OS need to be defined")
Expand Down Expand Up @@ -208,7 +208,7 @@ function splitext(path::String)
a, b = splitdrive(path)
m = match(path_ext_splitter, b)
m === nothing && return (path,"")
a*m.captures[1], String(m.captures[2])
(a*something(m.captures[1])), String(something(m.captures[2]))
end

# NOTE: deprecated in 1.4
Expand Down

0 comments on commit f540b9c

Please sign in to comment.