-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
effect overrides: Add notaskstate & refactor slightly #45448
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The :total_may_throw
setting is backported to v1.8 and so this can be breaking if we don't backport it.
base/expr.jl
Outdated
val = true | ||
org_setting = setting | ||
while true | ||
if isa(setting, Expr) && setting.head === :call | ||
if setting.args[1] == :(!) | ||
val = !val | ||
setting = setting.args[2] | ||
end | ||
elseif isa(setting, QuoteNode) && isa(setting.value, Symbol) | ||
setting = setting.value | ||
else | ||
break | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val = true | |
org_setting = setting | |
while true | |
if isa(setting, Expr) && setting.head === :call | |
if setting.args[1] == :(!) | |
val = !val | |
setting = setting.args[2] | |
end | |
elseif isa(setting, QuoteNode) && isa(setting.value, Symbol) | |
setting = setting.value | |
else | |
break | |
end | |
end | |
org_setting = setting | |
setting, val = compute_setting(setting) |
with
function compute_setting(@nospecialize(setting), val::Bool=true)
if isexpr(setting, :call) && settings.args[1] === :(!)
return compute_setting(setting.args[2], !val)
elseif isa(setting, QuoteNode)
return compute_setting(setting.value, val)
else
return (setting, val)
end
end
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I'm assuming nobody will build exprs big enough that this bites us :)
I'll put up a PR to rename it to |
Hmm, I don't see it on 1.8 (https://github.com/JuliaLang/julia/blob/release-1.8/base/expr.jl#L538-L539). Is it pending in backport still? |
7d85fe1
to
3ca623b
Compare
It is still on the backport branch: Line 583 in 8bca2f4
|
This adds an effect override for `:notaskstate` and shifts the `:total`, meta-effect around slightly to prepare for any potential future expansion. In particular `:total` now means the maximum possible set of effects and should likely include any future additions. The assume_effects macro learned to do negation, so we can now write things like `:total :!nothrow`, which will be helpful writing tests that care about one effect in particular, but are otherwise total. The previous `:total_may_throw`, was renamed `:foldable` and includes the effects required to allow compile-time constant folding. At this point I don't anticipate the introduction of additional effects that would affect constant-foldability, but if such an effect were introduced, it would be added to `:foldable`. Note however, that `:foldable` does not include `:notaskstate` (though as noted in the docstring, because of the strong requirements of `:consistent` and `:effect_free`, it is implied that anything annotated `:notaskstate` may be DCEd and thus `:notaskstate` is implied). Nevertheless, `:notaskstate` is not included in the `:foldable` override and future effect additions may further separate `:foldable` from `:total`.
3ca623b
to
e0fc83f
Compare
Ok, then no packages could have possibly started using it, so we can just rename it to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This adds an effect override for
:notaskstate
and shifts the:total
, meta-effect around slightly to prepare for any potentialfuture expansion. In particular
:total
now means the maximumpossible set of effects and should likely include any future additions.
The assume_effects macro learned to do negation, so we can now write
things like
:total :!nothrow
, which will be helpful writing teststhat care about one effect in particular, but are otherwise total.
The previous
:total_may_throw
, was renamed:foldable
and includesthe effects required to allow compile-time constant folding. At this
point I don't anticipate the introduction of additional effects that
would affect constant-foldability, but if such an effect were introduced,
it would be added to
:foldable
. Note however, that:foldable
does not include
:notaskstate
(though as noted in the docstring,because of the strong requirements of
:consistent
and:effect_free
,it is implied that anything annotated
:notaskstate
may be DCEdand thus
:notaskstate
is implied). Nevertheless,:notaskstate
isnot included in the
:foldable
override and future effect additionsmay further separate
:foldable
from:total
.