Commit 0c46852
authored
Implements effects refinement that goes in the reverse direction of what
was implemented in 8dd0cf5.
In the discussion at #52268, there's a debate on how to
deal with exceptions
like `StackOverflowError` or `InterruptException` that are caused by
environment. The
original purpose of #52268 was to fix issues where methods that could
cause a
`StackOverflowError` were mistakenly refined to `:nothrow`. But now it
feels like it's a bit
weird to model such environment-dependent exceptions as `:nothrow` in
the first place. If we
can exclude environment-dependent errors from the `:nothrow` modeling,
those methods might
be safely considered `:nothrow`. To prevent the concrete evaluation of
methods that may
cause `StackOverflowError`, it's enough to taint its `:teminates` after
all.
This commit excludes environment-depending errors from the `:nothrow`
modeling, reverting the changes from #52268 while making it explicit in
the `Effects` and `Base.@assume_effects` docstrings.
Anyway, now the compile is able to prove `:nothrow`-ness of the
following frame:
```julia
function getindex_nothrow(xs::Vector{Int}, i::Int)
try
return xs[i]
catch err
err isa BoundsError && return nothing
rethrow(err)
end
end
```
1 parent a624d44 commit 0c46852
File tree
5 files changed
+29
-8
lines changed- base
- compiler
- test/compiler
5 files changed
+29
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
466 | 471 | | |
467 | 472 | | |
468 | 473 | | |
| |||
883 | 888 | | |
884 | 889 | | |
885 | 890 | | |
886 | | - | |
887 | | - | |
888 | | - | |
889 | 891 | | |
890 | 892 | | |
891 | 893 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
552 | 552 | | |
553 | 553 | | |
554 | 554 | | |
555 | | - | |
| 555 | + | |
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
| |||
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
564 | | - | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
565 | 569 | | |
566 | 570 | | |
567 | 571 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1290 | 1290 | | |
1291 | 1291 | | |
1292 | 1292 | | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
427 | 426 | | |
428 | 427 | | |
429 | 428 | | |
430 | 429 | | |
431 | 430 | | |
432 | | - | |
433 | 431 | | |
434 | 432 | | |
435 | 433 | | |
| |||
5560 | 5558 | | |
5561 | 5559 | | |
5562 | 5560 | | |
5563 | | - | |
| 5561 | + | |
5564 | 5562 | | |
5565 | 5563 | | |
5566 | 5564 | | |
| |||
0 commit comments