-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdmd.fastdfa.dd
More file actions
31 lines (24 loc) · 1.54 KB
/
dmd.fastdfa.dd
File metadata and controls
31 lines (24 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
New experimental Data Flow Analysis Engine for nullability and truthiness
A new experimental Data Flow Analysis (DFA) has been implemented under the preview flag ``-preview=fastdfa``.
The intent of the engine is to be both fast and free from false positives, if successful it may in the future be turned on by default.
No attributes have been implemented to date, before they are considered the engine itself must be both usable with the right tradeoffs and have desirable features.
This has some side effects, it prevent separate compilation, function pointers, and cyclic functions from being analysable.
These limitations are not supposed to prevent a successful compilation when in use.
The engine itself is variable centric with a strong focus on giving up on analysing a variable if things get too complex for it.
This can result in messages that may not appear to make sense for where they are emitted, due to the way shortcutting of analysis works.
As an example of loops:
```d
void loopy()
{
int* ptr = new int;
foreach (i; 0 .. 2) // Error: Variable `ptr` was required to be non-null and has become null
{
int val = *ptr;
ptr = null;
}
}
```
If the engine is successful, the reporting mechanism would be replaced with a tracing state pass.
This would offer for a function line by line explanation of how and why the engine thought something was true.
The engine has been tested on a 100k LOC defensively written codebase without any false positives.
The performance is similar to DIP1000 and is not supposed to be noticeable.