-
-
Notifications
You must be signed in to change notification settings - Fork 668
PoC DFA engine for nullability and truthiness #21965
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
Conversation
|
Thanks for your pull request and interest in making D better, @rikkimax! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#21965" |
|
Will retrigger after: #21966 |
|
dependant PR merged |
|
Calling it fast DFA implies there is or will be a slow one. Is there going to be a slow one or can we move all of the |
If it succeeds, then yes, I intend to also implement a slow DFA. The slow DFA is meant to be more false positive heavy, but also more accurate. Requiring the use of attributes and changing of code to satisfy the DFA. This would be opt-in. The fast DFA is meant to be free of false positives, but not necessarily able to model all code. No attributes or changing of code is meant to happen unless it is in some way bad. This would be on by default. Different target audiences. So they are quite opposite of each other. |
|
Why hasn't this been merged? |
|
Well it still has PoC in the title of the PR for one, I take it that it is good to go now? |
|
Yes. It is PoC since no attributes, and missing features rather than PR being incomplete for its scope. |
|
Okay something changed since the testsuite ran. |
|
Oh, you want |
|
It was moved out of being a method, and put as a free-function in expressionsem, fixing. |
|
Of you way need to |
|
This is awesome! How come this was approved so quickly? Are we suddenly more liberal in adding new |
Sort of. I proposed adding it under a preview switch a few months ago, but I placed some rules upon myself to minimize risk:
This approach has been applied to Walter's work with the ARM backend. I also got permission for Stefan, to do the same for newCTFE but he hasn't done a PR yet. Better to merge something that is low risk under a preview switch than to see 6+ months worth of work wasted, times X. And thanks :) |
This is fantastic news. Thanks for doing this. I too did experiment with dmd detection of unused variables years ago. What about Stefans' work on type functions? |
|
What about extending this DFA to also cover referencing of non-intialized variable values or pointes in cases such as int *x = void;
auto y = *x; // should error? |
If I remember right he gave up on it, and it is full of risk to try to do something like this with that.
Originally I wanted to model type state as a whole, with nullability being a later value after uninitialized. I may yet decide to implement it. For now though it's very incremental in development, and I need to see it succeeding before using more of my time on it. |
|
Do you have a list of upcoming diagnostics that make use of the infrastructure added here? Just curious which of these that overlap with my pre-existing work and feature requests. |
|
I do not no, I have goals but the exact order isn't known to me currently. But the end goal is to try to get a borrow checker akin to what people expect. Anything else is a nice (but intended) bonus. |
|
This PR introduced a regression dmd/compiler/src/dmd/semantic3.d Lines 1164 to 1166 in 24a4107
|
| FeatureState dtorFields; // destruct fields of partially constructed objects | ||
| // https://issues.dlang.org/show_bug.cgi?id=14246 | ||
| FeatureState systemVariables; // limit access to variables marked @system from @safe code | ||
| bool useFastDFA; // Use fast data flow analysis engine |
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.
... it would seem this is the regressing line.
Apart from one CI that was timed out, it was green in previous PR: #21494