Skip to content

Commit

Permalink
fix: make compiler happier in is_squarefree (#1669)
Browse files Browse the repository at this point in the history
Fix the following compiler bug when using Hecke:
```
julia> @code_warntype is_squarefree(x)
MethodInstance for AbstractAlgebra.is_squarefree(::ZZPolyRingElem)
  from is_squarefree(f::PolyRingElem{<:RingElement}) @ Nemo ~/Nemo/src/HeckeMiscPoly.jl:517
Arguments
  #self#::Core.Const(AbstractAlgebra.is_squarefree)
  f::ZZPolyRingElem
Locals
  #1096::Nemo.var"#1096#1097"
  fac::Fac{ZZPolyRingElem}
Body::Any
```
  • Loading branch information
thofma authored Feb 9, 2024
1 parent 1019efb commit 2107727
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Nemo"
uuid = "2edaba10-b0f1-5616-af89-8c11ac63239a"
version = "0.41.4"
version = "0.41.5"

[deps]
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
Expand Down
2 changes: 1 addition & 1 deletion src/HeckeMiscInteger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ function is_squarefree(n::Union{Int,ZZRingElem})
if e > 1
return false
end
return isone(maximum(values(factor(n).fac)))
return isone(maximum(values(factor(n).fac); init = 1))
end


Expand Down
2 changes: 1 addition & 1 deletion src/HeckeMiscPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ end

function is_squarefree(f::PolyRingElem{<:RingElement})
iszero(f) && return false
degree(f) == 0 && return is_squarefree(leading_coefficient(f))
degree(f) == 0 && return is_squarefree(leading_coefficient(f))::Bool
fac = factor_squarefree(f)
return all(e <= 1 for (_, e) in fac)
end

0 comments on commit 2107727

Please sign in to comment.