-
-
Notifications
You must be signed in to change notification settings - Fork 667
Print deprecation messages except if -revert=dip1000 is used #12578
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, @atilaneves! 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#12578" |
src/dmd/escape.d
Outdated
| void unsafeAssign(VarDeclaration v, const char* desc) | ||
| { | ||
| if (global.params.useDIP1000 == FeatureState.enabled && sc.func.setUnsafe()) | ||
| if (sc.func.setUnsafe()) |
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.
Doesn't this (and the change at L1045) change the semantic of programs not using DIP1000 as well ?
setUnsafe has side effect. We had a bug related to it: https://github.com/dlang/dmd/pull/12127/files#diff-1a1c16e5ec319550bcd4ecb5d3f4ca6ca7ffad78af91f077603617117bb7d0c7R1037-R1038
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.
Ah, I hadn't considered the short-circuiting nature of the check. Thanks!
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.
After checking the code, I think this is fine, since it only has a side-effect when the compiler is determining safety anyway.
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.
Some projects on buildkite are currently failing because formerly @safe functions are now inferred @system, probably because of this setUnsafe()
|
I'm not sure I understand the purpose of that PR ? Turn DIP1000 on by default, but with errors as deprecations ? |
The aim is indeed to to do what was done for DIP25. I don't think "turn on DIP1000" is accurate - the goal is first to annoy users with deprecation messages and force them to use
|
👍 👍
The point of
IOW, something completely unacceptable.
|
|
Am I missing something wrt DIP1000 design decisions? AFAIK we "only" have to fix bugs. |
|
DIP1000 does suffer from some bugs, however, every feature does. What would be the point when we can safely say "now is the time to enable dip1000 by default"? Are there any glaring holes that need to be fix first? If not, I think that we can go ahead and merge this PR. |
Yes, issue 20150 is particularly egregious. |
When DIP1000 allow to achieve its stated goal: |
I agree this is a blocker. It's one thing for DIP1000 to not catch all memory safety errors due to a bug, it's another entirely to start compiling code that it didn't before that isn't memory safe. |
7c7ce6c to
5670235
Compare
|
The blocking issue has been fixed, so I see no reason to not merge this. |
|
There's still this: https://issues.dlang.org/show_bug.cgi?id=22221 |
|
Also commit message / PR title needs an update |
Do they? |
That's... not ideal. But I wouldn't consider it a blocker. Definitely needs to be fixed, though. |
Ah, reading again, I see what you mean. I thought it was the original idea of "Print a deprecation message if the user isn't using DIP1000", not "Start deprecating constructs that would error with |
The dmd fix is easy (#12989), the hard part is not breaking Phobos (dlang/phobos#8214). It turns out that fixing
If you annotate
So what do I fear happens when this PR is merged? People upgrade to dmd 2.099 and are presented with a flood of inscrutable deprecation errors, lots of them based on false positives because of bad |
fbb4685 to
33341ee
Compare
|
Woohoo, green! |
|
I addressed the latest review comments. |
|
|
||
| As an incentive to transition to -preview=dip1000 by default, now the | ||
| compiler prints what would have been error messages if the flag had | ||
| been on as deprecation messages. This new behaviour can be disabled |
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.
Only in explicit @safe functions, function with inference may still silently be @safe while having scope violations.
|
The bigger problem with the changelog entry is that it leaves users clueless: what is DIP1000? What does this mean for my code? Where can I find documentation? There's no tutorial, and the spec is not up to date (dlang/dlang.org#3262 for one, but there's more). While I approve the PR for what is does, I would say it's "blocked" by the lack of documentation. |
5ec7ffb to
5dd5d5d
Compare
Co-authored-by: Dennis <dkorpel@users.noreply.github.com>
|
I agree we need more documentation, but I don't think that this PR is the place to do it - I can't link to something outdated. What do you suggest to make the changelog entry better? |
5dd5d5d to
8020446
Compare
I'm working on writing documentation for DIP1000. What we could do is already merge this, and then improve the changelog in a subsequent PR, since there is still time before the next release. This way you don't have to keep rebasing this PR in the meantime. |
| @@ -0,0 +1,6 @@ | |||
| Print warning messages unless -revert=dip1000 is used | |||
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.
I guess the little detail of adding this option was overlooked? :-)
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.
Yes, unfortunately: #14019
I think this doesn't cover all of them given that I only had to change one test. There are a lot of checks for DIP1000 in the codebase but that don't immediately print out error messages.
I figured it was best to do this part first and investigate more later.