JuliaMath / Primes.jl

Prime numbers in Julia
Other
99 stars 32 forks source link

`factor(SafeInt128(8))` returns an error #145

Closed lampretl closed 11 months ago

lampretl commented 11 months ago

In Julia 1.9.2 using Primes v0.5.4 and SaferIntegers v3.4.0, the code

using Primes, SaferIntegers
factor(SafeInt128(8))

returns

ERROR: MethodError: no method matching increment!(::Primes.Factorization{SafeInt128}, ::SafeInt64, ::SafeInt128)

Closest candidates are:
  increment!(::Primes.Factorization{T}, ::Int64, ::Any) where T
   @ Primes ~/.julia/packages/Primes/sH6Tw/src/factorization.jl:48
  increment!(::AbstractDict, ::Int64, ::Any)
   @ Primes ~/.julia/packages/Primes/sH6Tw/src/factorization.jl:59

Stacktrace:
 [1] factor!(n::SafeInt128, h::Primes.Factorization{SafeInt128})
   @ Primes ~/.julia/packages/Primes/sH6Tw/src/Primes.jl:394
 [2] factor(n::SafeInt128)
   @ Primes ~/.julia/packages/Primes/sH6Tw/src/Primes.jl:429
 [3] top-level scope
   @ REPL[3]:1
oscardssmith commented 11 months ago

was it working previously?

lampretl commented 11 months ago

What do you mean by previously? I don't think I used factor(::SafeInt128) until today.

oscardssmith commented 11 months ago

I just wanted to make sure this wasn't a regression. Can you test to see if https://github.com/JuliaMath/Primes.jl/pull/146 fixes this?

lampretl commented 11 months ago

In the environment I am using, I ran ] add Primes#efb632fb6b781145db8f6c7fe33b94866dc8b466 then rebooted Julia and ran factor(SafeInt128(8)). This time, there was no error.

I suppose this is the intended way how updates/fixes to packages are supposed to be used by regular users?

Thank you for such a quick reply!

oscardssmith commented 11 months ago

Thanks for testing this! version 0.5.5 should be out in roughly 15 minutes with this change.