Skip to content

Commit 671fc42

Browse files
authored
copy effects key to Base.infer_effects (JuliaLang#56363)
Copied from the docstring of `Core.Compiler.Effects`, this makes it easier to figure out what the output of `Base.infer_effects` is actually telling you.
1 parent 715eb1d commit 671fc42

File tree

2 files changed

+42
-35
lines changed

2 files changed

+42
-35
lines changed

base/compiler/effects.jl

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1+
const effects_key_string = """
2+
## Key for `show` output of Effects:
3+
4+
The output represents the state of different effect properties in the following order:
5+
6+
1. `consistent` (`c`):
7+
- `+c` (green): `ALWAYS_TRUE`
8+
- `-c` (red): `ALWAYS_FALSE`
9+
- `?c` (yellow): `CONSISTENT_IF_NOTRETURNED` and/or `CONSISTENT_IF_INACCESSIBLEMEMONLY`
10+
2. `effect_free` (`e`):
11+
- `+e` (green): `ALWAYS_TRUE`
12+
- `-e` (red): `ALWAYS_FALSE`
13+
- `?e` (yellow): `EFFECT_FREE_IF_INACCESSIBLEMEMONLY`
14+
3. `nothrow` (`n`):
15+
- `+n` (green): `true`
16+
- `-n` (red): `false`
17+
4. `terminates` (`t`):
18+
- `+t` (green): `true`
19+
- `-t` (red): `false`
20+
5. `notaskstate` (`s`):
21+
- `+s` (green): `true`
22+
- `-s` (red): `false`
23+
6. `inaccessiblememonly` (`m`):
24+
- `+m` (green): `ALWAYS_TRUE`
25+
- `-m` (red): `ALWAYS_FALSE`
26+
- `?m` (yellow): `INACCESSIBLEMEM_OR_ARGMEMONLY`
27+
7. `noub` (`u`):
28+
- `+u` (green): `true`
29+
- `-u` (red): `false`
30+
- `?u` (yellow): `NOUB_IF_NOINBOUNDS`
31+
8. `:nonoverlayed` (`o`):
32+
- `+o` (green): `ALWAYS_TRUE`
33+
- `-o` (red): `ALWAYS_FALSE`
34+
- `?o` (yellow): `CONSISTENT_OVERLAY`
35+
9. `:nortcall` (`r`):
36+
- `+r` (green): `true`
37+
- `-r` (red): `false`
38+
"""
39+
140
"""
241
effects::Effects
342
@@ -74,42 +113,8 @@ initialized with `ALWAYS_TRUE`/`true` and then transitioned towards `ALWAYS_FALS
74113
Note that within the current flow-insensitive analysis design, effects detected by local
75114
analysis on each statement usually taint the global conclusion conservatively.
76115
77-
## Key for `show` output of Effects:
78116
79-
The output represents the state of different effect properties in the following order:
80-
81-
1. `consistent` (`c`):
82-
- `+c` (green): `ALWAYS_TRUE`
83-
- `-c` (red): `ALWAYS_FALSE`
84-
- `?c` (yellow): `CONSISTENT_IF_NOTRETURNED` and/or `CONSISTENT_IF_INACCESSIBLEMEMONLY`
85-
2. `effect_free` (`e`):
86-
- `+e` (green): `ALWAYS_TRUE`
87-
- `-e` (red): `ALWAYS_FALSE`
88-
- `?e` (yellow): `EFFECT_FREE_IF_INACCESSIBLEMEMONLY`
89-
3. `nothrow` (`n`):
90-
- `+n` (green): `true`
91-
- `-n` (red): `false`
92-
4. `terminates` (`t`):
93-
- `+t` (green): `true`
94-
- `-t` (red): `false`
95-
5. `notaskstate` (`s`):
96-
- `+s` (green): `true`
97-
- `-s` (red): `false`
98-
6. `inaccessiblememonly` (`m`):
99-
- `+m` (green): `ALWAYS_TRUE`
100-
- `-m` (red): `ALWAYS_FALSE`
101-
- `?m` (yellow): `INACCESSIBLEMEM_OR_ARGMEMONLY`
102-
7. `noub` (`u`):
103-
- `+u` (green): `true`
104-
- `-u` (red): `false`
105-
- `?u` (yellow): `NOUB_IF_NOINBOUNDS`
106-
8. `:nonoverlayed` (`o`):
107-
- `+o` (green): `ALWAYS_TRUE`
108-
- `-o` (red): `ALWAYS_FALSE`
109-
- `?o` (yellow): `CONSISTENT_OVERLAY`
110-
9. `:nortcall` (`r`):
111-
- `+r` (green): `true`
112-
- `-r` (red): `false`
117+
$(effects_key_string)
113118
"""
114119
struct Effects
115120
consistent::UInt8

base/reflection.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,8 @@ signature, the `:nothrow` bit gets tainted.
877877
The `Base.infer_effects` function should not be used from generated functions;
878878
doing so will result in an error.
879879
880+
$(Core.Compiler.effects_key_string)
881+
880882
# See Also
881883
- [`Core.Compiler.Effects`](@ref): A type representing the computational effects of a method call.
882884
- [`Base.@assume_effects`](@ref): A macro for making assumptions about the effects of a method.

0 commit comments

Comments
 (0)