invalid usage of @assume_effects
in base/irrationals.jl
#55874
Labels
kind:bug
Indicates an unexpected problem or unintended behavior
There are four methods with
@assume_effects :total
applied to the entire method inbase/irrationals.jl
:julia/base/irrationals.jl
Line 55 in 6e5e87b
julia/base/irrationals.jl
Lines 70 to 71 in 6e5e87b
julia/base/irrationals.jl
Lines 113 to 120 in 6e5e87b
Issues:
:total
effect is too powerful and not future-proof. I guess what's actually desired is just:foldable
.@assume_effects
to the::AbstractIrrational
methods, because users may define custom subtypes ofAbstractIrrational
, and thus calls likeBigFloat(::AbstractIrrational)
orbig(::AbstractIrrational)
may execute arbitrary code. That said ...@assume_effects
even just for::Irrational
, because users may define custom subtypes ofIrrational
! Example:This seems perfectly legal, or at least it's not type piracy.
The solution seems simple: define a
Union
of all known irrational constants, something like the following, then dispatch on it for methods that have@assume_effects
, instead of onAbstractIrrational
or onIrrational
:This will ensure calls involving the known constants are foldable, and allow the unsafe
@assume_effects
annotations to be deleted. Will make a PR later.The text was updated successfully, but these errors were encountered: