From 2107727eccb1c38905962922a7797b0e63c16328 Mon Sep 17 00:00:00 2001 From: Tommy Hofmann Date: Fri, 9 Feb 2024 22:46:16 +0100 Subject: [PATCH] fix: make compiler happier in is_squarefree (#1669) 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 ``` --- Project.toml | 2 +- src/HeckeMiscInteger.jl | 2 +- src/HeckeMiscPoly.jl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index a6f0b6c43f..4c0427a0c7 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/HeckeMiscInteger.jl b/src/HeckeMiscInteger.jl index 0f8292a59b..d0622ce737 100644 --- a/src/HeckeMiscInteger.jl +++ b/src/HeckeMiscInteger.jl @@ -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 diff --git a/src/HeckeMiscPoly.jl b/src/HeckeMiscPoly.jl index 752515d93b..6de828a2f1 100644 --- a/src/HeckeMiscPoly.jl +++ b/src/HeckeMiscPoly.jl @@ -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