Skip to content

Commit acc31a4

Browse files
yuyichaoararslan
authored andcommitted
Fix depwarns on 0.7 (#57)
1 parent 2267021 commit acc31a4

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
julia 0.5
2-
Compat 0.18.0
2+
Compat 0.30.0

src/Primes.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,10 @@ julia> isprime(big(3))
178178
true
179179
```
180180
"""
181-
isprime(x::BigInt, reps=25) = ccall((:__gmpz_probab_prime_p,:libgmp), Cint, (Ptr{BigInt}, Cint), &x, reps) > 0
181+
isprime(x::BigInt, reps=25) = ccall((:__gmpz_probab_prime_p,:libgmp),
182+
Cint, (Any, Cint), x, reps) > 0
183+
# TODO: Change `Any` to `Ref{BigInt}` when 0.6 support is dropped.
184+
# The two have the same effect but `Ref{BigInt}` won't be optimized on 0.6.
182185

183186

184187
# Miller-Rabin witness choices based on:
@@ -535,10 +538,12 @@ end
535538

536539
# modify a BigInt in-place
537540
function add_!(n::BigInt, x::Int)
541+
# TODO: Change `Any` to `Ref{BigInt}` when 0.6 support is dropped.
542+
# The two have the same effect but `Ref{BigInt}` won't be optimized on 0.6.
538543
if x < 0
539-
ccall((:__gmpz_sub_ui, :libgmp), Void, (Ptr{BigInt}, Ptr{BigInt}, Culong), &n, &n, -x)
544+
ccall((:__gmpz_sub_ui, :libgmp), Void, (Any, Any, Culong), n, n, -x)
540545
else
541-
ccall((:__gmpz_add_ui, :libgmp), Void, (Ptr{BigInt}, Ptr{BigInt}, Culong), &n, &n, x)
546+
ccall((:__gmpz_add_ui, :libgmp), Void, (Any, Any, Culong), n, n, x)
542547
end
543548
n
544549
end
@@ -571,7 +576,7 @@ julia> nextprime(5, 2)
571576
"""
572577
function nextprime(n::Integer, i::Integer=1)
573578
i < 0 && return prevprime(n, -i)
574-
i == 0 && throw(DomainError())
579+
i == 0 && throw(DomainError(i))
575580
n < 2 && (n = oftype(n, 2))
576581
if n == 2
577582
if i <= 1
@@ -646,7 +651,7 @@ julia> prime(3)
646651
647652
```
648653
"""
649-
prime{T<:Integer}(::Type{T}, i::Integer) = i < 0 ? throw(DomainError()) : nextprime(T(2), i)
654+
prime{T<:Integer}(::Type{T}, i::Integer) = i < 0 ? throw(DomainError(i)) : nextprime(T(2), i)
650655
prime(i::Integer) = prime(Int, i)
651656

652657
end # module

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ end
291291
@test totient(2^4 * 3^4 * 5^4) == 216000
292292
@test totient(big"2"^1000) == big"2"^999
293293

294-
const some_coprime_numbers = BigInt[
294+
some_coprime_numbers = BigInt[
295295
450000000, 1099427429702334733, 200252151854851, 1416976291499, 7504637909,
296296
1368701327204614490999, 662333585807659, 340557446329, 1009091
297297
]

0 commit comments

Comments
 (0)