fix Issue 20150 - -dip1000 defeated by pure#12010
Conversation
|
Thanks for your pull request and interest in making D better, @aG0aep6G! 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 references
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#12010" |
|
@aG0aep6G What is the status on this? Are you planing on updating phobos to pass so that this passes the test suite? |
I had started on it, but it's tedious work tracking down the errors through templates and overloads. If I remember correctly, So I've put it on ice for the time being. If someone else wants to give it a shot, that would be great. |
|
@RazvanN7 and @aG0aep6G: What about modifying this diagnostics to emit a deprecation message for the new case not covered by phobos and many other projects? To buy us time to adjust Phobos and many other projects before this diagnostics is turned into a new error and in the meantime have a way to detect vulnerabilities recently discussed at https://forum.dlang.org/thread/jnkdcngzytgtobihzggj@forum.dlang.org?page=1 |
I don't think that's a good idea. Issue 20150 is a straight-forward bug. Let's not bend over backwards to accommodate buggy code. |
Agreed. My motive was about getting this diagnostics into the compiler without having to first correct loads of failing dub-packages in buildkite [1]. It would be nice to be able to see how many of those that break wihtout having to first correct all the failing unittests in phobos (being the one remaining). |
|
Have you studied the 130 dmd tests that fail with this change and the phobos error messages that are triggered by this? For instance @safe pure nothrow unittest
{
assert("Hello D".array == "Hello D"d);
}fails as The number of errors triggered is massive. |
Going down that one rabbit hole:
2
Yeah, issue 20150 is a serious bug. |
Thank you! |
Could such tedious manual labour be partially automated by an extension of #12383, @MoonlightSentinel ? |
|
@nordlow for dlang/druntime#3480 I hacked dmd to warn about violations without giving errors or setting functions to |
| return stc; | ||
| } | ||
|
|
||
| stc |= STC.scope_; |
There was a problem hiding this comment.
I just realized there should also be a check that the function is nothrow, or else parameters could escape using Exceptions.
import std.stdio;
void escape(string x) @safe pure {
throw new Exception(x);
}
void main() @safe {
static string global;
immutable(char)[4] local;
try {
escape(local[]);
} catch(Exception e) {
global = e.msg;
}
assert(&local[0] != &global[0]); // fails
}Though that might be better to do in a follow-up PR, so we can get the fix for the more common case in quicker.
|
Now dlang/phobos#8113 has been merged, can you rebase this @aG0aep6G? Phobos and druntime now compile locally for me on Linux, so I wonder about other platforms and buildkite. |
rebased |
|
Looks we have some work adjusting DUB packages. |
|
Strange error at https://buildkite.com/dlang/dmd/builds/21202#25829e63-52ab-4f46-a04f-c8b88e0d27ba/456-1553. |
First one: atilaneves/unit-threaded#254 |
I believe @atilaneves is on vacation. :) |
Probably because an array literal used in a -betterC unittest that used to be on the stack is now GC allocated, since parameters of |
|
Now that atilaneves/unit-threaded#254 is merged what remains, @dkorpel? |
I think @atilaneves needs to ensure automem uses the latest unit-threaded (with the scope fixes), and then @aG0aep6G should rebase again, and hopefully it's green then. |
The project kaleidicassociates/excel-d also seem to need som tlc; https://buildkite.com/dlang/dmd/builds/21202#f8d3a21a-304b-4a32-9e9e-dfa7263075d4/115-145. |
|
Should be fixed by symmetryinvestments/excel-d#95 |
Great. Thanks. |
excel-d is now the last red project on buildkite. |
Seems like a trivial fix. I'll look into it. |
Calling @atilaneves commited a fix for this issue via symmetryinvestments/excel-d#95. |
|
Ahh, maybe excel-d just lacks a tag bump (to v0.5.10), @aG0aep6G and @atilaneves. Can you push a new tag v0.5.10 of excel-d, @atilaneves? Does the buildkite job automatically pick the latest tag, @aG0aep6G? |
FYI, @RazvanN7 |
Yes, should be fixed by #12985
Yes, though I consider improving scope inference first (issue 20674) to minimize the new amount of breakage it will give.
I've closed it now, it's clear that it's the wrong approach. |
|
Awesome. |
This is an alternative to #10924, fixing issue 20150 without introducing a rejects-valid regression.
Phobos relies on issue 20150, so this is expected to fail the test suite.