• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #38182

15 Aug 2025 03:55AM UTC coverage: 77.87% (-0.4%) from 78.28%
#38182

push

local

web-flow
🤖 [master] Bump the SparseArrays stdlib from 30201ab to bb5ecc0 (#59263)

Stdlib: SparseArrays
URL: https://github.com/JuliaSparse/SparseArrays.jl.git
Stdlib branch: main
Julia branch: master
Old commit: 30201ab
New commit: bb5ecc0
Julia version: 1.13.0-DEV
SparseArrays version: 1.13.0
Bump invoked by: @ViralBShah
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
https://github.com/JuliaSparse/SparseArrays.jl/compare/30201abcb...bb5ecc091

```
$ git log --oneline 30201ab..bb5ecc0
bb5ecc0 fast quadratic form for dense matrix, sparse vectors (#640)
34ece87 Extend 3-arg `dot` to generic `HermOrSym` sparse matrices (#643)
095b685 Exclude unintended complex symmetric sparse matrices from 3-arg `dot` (#642)
8049287 Fix signature for 2-arg matrix-matrix `dot` (#641)
cff971d Make cond(::SparseMatrix, 1 / Inf) discoverable from 2-norm error (#629)
```

Co-authored-by: ViralBShah <744411+ViralBShah@users.noreply.github.com>

48274 of 61993 relevant lines covered (77.87%)

9571166.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.84
/base/version.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
## semantic version numbers (https://semver.org/)
4

5
const VerTuple = Tuple{Vararg{Union{UInt64,String}}}
6

7
const VInt = UInt32
8
"""
9
    VersionNumber
10

11
Version number type which follows the specifications of
12
[semantic versioning (semver)](https://semver.org/spec/v2.0.0-rc.2.html), composed of major, minor
13
and patch numeric values, followed by pre-release and build
14
alphanumeric annotations.
15

16
`VersionNumber` objects can be compared with all of the standard comparison
17
operators (`==`, `<`, `<=`, etc.), with the result following semver v2.0.0-rc.2 rules.
18

19
`VersionNumber` has the following public fields:
20
- `v.major::Integer`
21
- `v.minor::Integer`
22
- `v.patch::Integer`
23
- `v.prerelease::Tuple{Vararg{Union{Integer, AbstractString}}}`
24
- `v.build::Tuple{Vararg{Union{Integer, AbstractString}}}`
25

26
See also [`@v_str`](@ref) to efficiently construct `VersionNumber` objects
27
from semver-format literal strings, [`VERSION`](@ref) for the `VersionNumber`
28
of Julia itself, and [Version Number Literals](@ref man-version-number-literals)
29
in the manual.
30

31
# Examples
32
```jldoctest
33
julia> a = VersionNumber(1, 2, 3)
34
v"1.2.3"
35

36
julia> a >= v"1.2"
37
true
38

39
julia> b = VersionNumber("2.0.1-rc1")
40
v"2.0.1-rc1"
41

42
julia> b >= v"2.0.1"
43
false
44
```
45
"""
46
struct VersionNumber
47
    major::VInt
48
    minor::VInt
49
    patch::VInt
50
    prerelease::VerTuple
51
    build::VerTuple
52

53
    function VersionNumber(major::VInt, minor::VInt, patch::VInt,
531✔
54
                           @nospecialize(pre::VerTuple), @nospecialize(bld::VerTuple))
55
        major >= 0 || throw(ArgumentError("invalid negative major version: $major"))
4,521✔
56
        minor >= 0 || throw(ArgumentError("invalid negative minor version: $minor"))
3,558✔
57
        patch >= 0 || throw(ArgumentError("invalid negative patch version: $patch"))
2,596✔
58
        for ident in pre
1,657✔
59
            if ident isa Integer
120✔
60
                ident >= 0 || throw(ArgumentError("invalid negative pre-release identifier: $ident"))
3✔
61
            else
62
                if !occursin(r"^(?:|[0-9a-z-]*[a-z-][0-9a-z-]*)$"i, ident) ||
234✔
63
                    isempty(ident) && !(length(pre)==1 && isempty(bld))
64
                    throw(ArgumentError("invalid pre-release identifier: $(repr(ident))"))
×
65
                end
66
            end
67
        end
237✔
68
        for ident in bld
1,482✔
69
            if ident isa Integer
295✔
70
                ident >= 0 || throw(ArgumentError("invalid negative build identifier: $ident"))
25✔
71
            else
72
                if !occursin(r"^(?:|[0-9a-z-]*[a-z-][0-9a-z-]*)$"i, ident) ||
540✔
73
                    isempty(ident) && length(bld)!=1
74
                    throw(ArgumentError("invalid build identifier: $(repr(ident))"))
×
75
                end
76
            end
77
        end
587✔
78
        new(major, minor, patch, pre, bld)
2,599✔
79
    end
80
end
81
VersionNumber(major::Integer, minor::Integer = 0, patch::Integer = 0,
×
82
        pre::Tuple{Vararg{Union{Integer,AbstractString}}} = (),
83
        bld::Tuple{Vararg{Union{Integer,AbstractString}}} = ()) =
7,231✔
84
    VersionNumber(VInt(major), VInt(minor), VInt(patch),
85
        map(x->x isa Integer ? UInt64(x) : String(x), pre),
147✔
86
        map(x->x isa Integer ? UInt64(x) : String(x), bld))
167✔
87

88
VersionNumber(v::Tuple) = VersionNumber(v...)
2✔
89
VersionNumber(v::VersionNumber) = v
×
90

91
function print(io::IO, v::VersionNumber)
276✔
92
    v == typemax(VersionNumber) && return print(io, "∞")
276✔
93
    print(io, v.major)
276✔
94
    print(io, '.')
276✔
95
    print(io, v.minor)
276✔
96
    print(io, '.')
276✔
97
    print(io, v.patch)
276✔
98
    if !isempty(v.prerelease)
480✔
99
        print(io, '-')
204✔
100
        join(io, v.prerelease,'.')
204✔
101
    end
102
    if !isempty(v.build)
276✔
103
        print(io, '+')
×
104
        join(io, v.build,'.')
×
105
    end
106
end
107
show(io::IO, v::VersionNumber) = print(io, "v\"", v, "\"")
1✔
108

109
Broadcast.broadcastable(v::VersionNumber) = Ref(v)
×
110

111
const VERSION_REGEX = r"^
112
    v?                                      # prefix        (optional)
113
    (\d+)                                   # major         (required)
114
    (?:\.(\d+))?                            # minor         (optional)
115
    (?:\.(\d+))?                            # patch         (optional)
116
    (?:(-)|                                 # pre-release   (optional)
117
    ([a-z][0-9a-z-]*(?:\.[0-9a-z-]+)*|-(?:[0-9a-z-]+\.)*[0-9a-z-]+)?
118
    (?:(\+)|
119
    (?:\+((?:[0-9a-z-]+\.)*[0-9a-z-]+))?    # build         (optional)
120
    ))
121
$"ix
122

123
function split_idents(s::AbstractString)
138✔
124
    idents = eachsplit(s, '.')
138✔
125
    pidents = Union{UInt64,String}[occursin(r"^\d+$", ident) ? parse(UInt64, ident) : String(ident) for ident in idents]
138✔
126
    return tuple(pidents...)::VerTuple
138✔
127
end
128

129
function tryparse(::Type{VersionNumber}, v::AbstractString)
260✔
130
    v == "∞" && return typemax(VersionNumber)
260✔
131
    m = match(VERSION_REGEX, String(v)::String)
260✔
132
    m === nothing && return nothing
260✔
133
    major, minor, patch, minus, prerl, plus, build = m.captures
260✔
134
    major = parse(VInt, major::AbstractString)
260✔
135
    minor = minor !== nothing ? parse(VInt, minor) : VInt(0)
260✔
136
    patch = patch !== nothing ? parse(VInt, patch) : VInt(0)
264✔
137
    if prerl !== nothing && !isempty(prerl) && prerl[1] == '-'
376✔
138
        prerl = prerl[2:end] # strip leading '-'
116✔
139
    end
140
    prerl = prerl !== nothing ? split_idents(prerl) : minus !== nothing ? ("",) : ()
404✔
141
    build = build !== nothing ? split_idents(build) : plus  !== nothing ? ("",) : ()
498✔
142
    return VersionNumber(major, minor, patch, prerl::VerTuple, build::VerTuple)
260✔
143
end
144

145
function parse(::Type{VersionNumber}, v::AbstractString)
2✔
146
    ver = tryparse(VersionNumber, v)
761✔
147
    ver === nothing && throw(ArgumentError("invalid version string: $v"))
761✔
148
    return ver
760✔
149
end
150

151
VersionNumber(v::AbstractString) = parse(VersionNumber, v)
759✔
152

153
"""
154
    @v_str
155

156
String macro used to parse a string to a [`VersionNumber`](@ref).
157

158
# Examples
159
```jldoctest
160
julia> v"1.2.3"
161
v"1.2.3"
162

163
julia> v"2.0.1-rc1"
164
v"2.0.1-rc1"
165
```
166
"""
167
macro v_str(v); VersionNumber(v); end
292✔
168

169
function typemax(::Type{VersionNumber})
170
    ∞ = typemax(VInt)
270✔
171
    VersionNumber(∞, ∞, ∞, (), ("",))
276✔
172
end
173

174
typemin(::Type{VersionNumber}) = v"0-"
×
175

176
ident_cmp(a::Integer, b::Integer) = cmp(a, b)
8✔
177
ident_cmp(a::Integer, b::String ) = isempty(b) ? +1 : -1
×
178
ident_cmp(a::String,  b::Integer) = isempty(a) ? -1 : +1
×
179
ident_cmp(a::String,  b::String ) = cmp(a, b)
16✔
180

181
function ident_cmp(@nospecialize(A::VerTuple), @nospecialize(B::VerTuple))
52✔
182
    for (a, b) in Iterators.Zip{Tuple{VerTuple,VerTuple}}((A, B))
62✔
183
        c = ident_cmp(a, b)
24✔
184
        (c != 0) && return c
16✔
185
    end
24✔
186
    length(A) < length(B) ? -1 :
54✔
187
    length(B) < length(A) ? +1 : 0
188
end
189

190
function ==(a::VersionNumber, b::VersionNumber)
191
    (a.major != b.major) && return false
995✔
192
    (a.minor != b.minor) && return false
710✔
193
    (a.patch != b.patch) && return false
597✔
194
    (ident_cmp(a.prerelease, b.prerelease) != 0) && return false
547✔
195
    (ident_cmp(a.build, b.build) != 0) && return false
547✔
196
    return true
547✔
197
end
198

199
issupbuild(v::VersionNumber) = length(v.build)==1 && isempty(v.build[1])
765✔
200

201
function isless(a::VersionNumber, b::VersionNumber)
202
    (a.major < b.major) && return true
2,369✔
203
    (a.major > b.major) && return false
2,038✔
204
    (a.minor < b.minor) && return true
2,022✔
205
    (a.minor > b.minor) && return false
1,601✔
206
    (a.patch < b.patch) && return true
1,105✔
207
    (a.patch > b.patch) && return false
855✔
208
    (!isempty(a.prerelease) && isempty(b.prerelease)) && return true
423✔
209
    (isempty(a.prerelease) && !isempty(b.prerelease)) && return false
255✔
210
    c = ident_cmp(a.prerelease,b.prerelease)
255✔
211
    (c < 0) && return true
255✔
212
    (c > 0) && return false
255✔
213
    (!issupbuild(a) && issupbuild(b)) && return true
255✔
214
    (issupbuild(a) && !issupbuild(b)) && return false
255✔
215
    c = ident_cmp(a.build,b.build)
171✔
216
    (c < 0) && return true
171✔
217
    return false
171✔
218
end
219

220
function hash(v::VersionNumber, h::UInt)
37✔
221
    h ⊻= 0x8ff4ffdb75f9fede % UInt
37✔
222
    h = hash(v.major, h)
37✔
223
    h = hash(v.minor, h)
37✔
224
    h = hash(v.patch, h)
37✔
225
    h = hash(v.prerelease, ~h)
50✔
226
    h = hash(v.build, ~h)
37✔
227
end
228

229
lowerbound(v::VersionNumber) = VersionNumber(v.major, v.minor, v.patch, ("",), ())
×
230
upperbound(v::VersionNumber) = VersionNumber(v.major, v.minor, v.patch, (), ("",))
×
231

232
thispatch(v::VersionNumber) = VersionNumber(v.major, v.minor, v.patch)
768✔
233
thisminor(v::VersionNumber) = VersionNumber(v.major, v.minor, 0)
678✔
234
thismajor(v::VersionNumber) = VersionNumber(v.major, 0, 0)
648✔
235

236
nextpatch(v::VersionNumber) = v < thispatch(v) ? thispatch(v) : VersionNumber(v.major, v.minor, v.patch+1)
×
237
nextminor(v::VersionNumber) = v < thisminor(v) ? thisminor(v) : VersionNumber(v.major, v.minor+1, 0)
×
238
nextmajor(v::VersionNumber) = v < thismajor(v) ? thismajor(v) : VersionNumber(v.major+1, 0, 0)
×
239

240
## julia version info
241

242
"""
243
    VERSION
244

245
A [`VersionNumber`](@ref) object describing which version of Julia is in use. See also
246
[Version Number Literals](@ref man-version-number-literals).
247
"""
248
const VERSION = try
249
    ver = VersionNumber(VERSION_STRING)
250
    if !isempty(ver.prerelease) && !GIT_VERSION_INFO.tagged_commit
251
        if GIT_VERSION_INFO.build_number >= 0
252
            ver = VersionNumber(ver.major, ver.minor, ver.patch, (ver.prerelease..., GIT_VERSION_INFO.build_number), ver.build)
253
        else
254
            println("WARNING: no build number found for pre-release version")
255
            ver = VersionNumber(ver.major, ver.minor, ver.patch, (ver.prerelease..., "unknown"), ver.build)
256
        end
257
    elseif GIT_VERSION_INFO.build_number > 0
258
        println("WARNING: ignoring non-zero build number for VERSION")
259
    end
260
    ver
261
catch e
262
    println("while creating Base.VERSION, ignoring error $e")
263
    VersionNumber(0)
264
end
265

266
const libllvm_version = if endswith(libllvm_version_string, "jl")
267
    # strip the "jl" SONAME suffix (JuliaLang/julia#33058)
268
    # (LLVM does never report a prerelease version anyway)
269
    VersionNumber(libllvm_version_string[1:end-2])
270
else
271
    VersionNumber(libllvm_version_string)
272
end
273

274
libllvm_path() = ccall(:jl_get_libllvm, Any, ())
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc