-
-
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
[compiler] Teach type inference that GotoIfNot
can throw
#48583
Conversation
91080e2
to
adee936
Compare
Previously, the effects system would ignore certain cases where `GotoIfNot` nodes would be capable of throwing; this resulted in simple examples such as the following being marked as `nothrow`: ``` julia> foo(x) = x > 0 ? x : 0 Base.infer_effects(foo, (Missing,)) (+c,+e,+n,+t,+s,+m,+i) ``` With this change, we correctly notice when a `GotoIfNot` node is given a non-`Bool` condition, annotate the basic block as possibly throwing, and further end type inference if the condition is provably non-`Bool`.
adee936
to
43235e9
Compare
Labeled as backport under the assumption that this is an effect bugfix for 1.9 as well. |
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.
Previously, the effects system would ignore certain cases where `GotoIfNot` nodes would be capable of throwing; this resulted in simple examples such as the following being marked as `nothrow`: ``` julia> foo(x) = x > 0 ? x : 0 Base.infer_effects(foo, (Missing,)) (+c,+e,+n,+t,+s,+m,+i) ``` With this change, we correctly notice when a `GotoIfNot` node is given a non-`Bool` condition, annotate the basic block as possibly throwing, and further end type inference if the condition is provably non-`Bool`. (cherry picked from commit 68ada71)
This causes a regression on 1.9 when backported in that |
does this also affect 1.10? |
It's in CI so 1.10 seems to be fine. I noticed on 1.9 due to test failure: Lines 481 to 482 in 6523b0c
|
Previously, the effects system would ignore certain cases where `GotoIfNot` nodes would be capable of throwing; this resulted in simple examples such as the following being marked as `nothrow`: ``` julia> foo(x) = x > 0 ? x : 0 Base.infer_effects(foo, (Missing,)) (+c,+e,+n,+t,+s,+m,+i) ``` With this change, we correctly notice when a `GotoIfNot` node is given a non-`Bool` condition, annotate the basic block as possibly throwing, and further end type inference if the condition is provably non-`Bool`.
Previously, the effects system would ignore certain cases where
GotoIfNot
nodes would be capable of throwing; this resulted in simple examples such as the following being marked asnothrow
:With this change, we correctly notice when a
GotoIfNot
node is given a non-Bool
condition, annotate the basic block as possibly throwing, and further end type inference if the condition is provably non-Bool
.