-
-
Notifications
You must be signed in to change notification settings - Fork 747
Trigger a hard error on deprecation messages #5546
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, @wilzbach! 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. |
5df0313 to
6369d3b
Compare
|
|
||
|
|
||
| /* | ||
| @safe pure @nogc unittest |
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.
Wasn't it possible to mark the unittest as deprecated, which allows testing deprecated code? Or was I dreaming?
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.
Nope, that does seem to work!
|
|
||
|
|
||
| /* | ||
| @safe pure @nogc unittest |
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.
Nope, that does seem to work!
6369d3b to
16b9188
Compare
Wow sweat - it works on my local machine :) |
wilzbach
left a comment
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.
Not sure how to handle the unittests in std.uni which access private symbols. I undocumented them for now to see whether it would pass all stages.
| } | ||
|
|
||
| /// | ||
| @safe pure unittest |
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.
CsvReader is private
| /// | ||
| @safe unittest | ||
| { | ||
| assert(unicode.Cyrillic.intersect('-').byInterval.empty); |
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.
generated/linux/release/64/publictests/std_uni.d(132): Deprecation: std.uni.InversionList!(GcPolicy).InversionList.intersect(U)(U rhs) if (isCodepointSet!U) is not visible from module std_uni
|
|
||
| /// | ||
| @system pure unittest | ||
| { |
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.
generated/linux/release/64/publictests/std_uni.d(192): Deprecation: std.uni.BitPacked(T, ulong sz) if (isIntegral!T || is(T : dchar)) is not visible from module std_uni
| } | ||
|
|
||
| /// | ||
| @safe unittest |
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.
generated/linux/release/64/publictests/std_uni.d(242): Deprecation: std.uni.Utf8Matcher!().Impl!(1, 2, 3, 4).Impl.subMatcher(SizesToPick...)() is not visible from module std_uni
generated/linux/release/64/publictests/std_uni.d(243): Deprecation: std.uni.Utf8Matcher!().Impl!(1, 2, 3, 4).Impl.subMatcher(SizesToPick...)() is not visible from module std_uni
generated/linux/release/64/publictests/std_uni.d(244): Deprecation: std.uni.Utf8Matcher!().Impl!(1, 2, 3, 4).Impl.subMatcher(SizesToPick...)() is not visible from module std_uni
generated/linux/release/64/publictests/std_uni.d(245): Deprecation: std.uni.Utf8Matcher!().Impl!(1, 2, 3, 4).Impl.subMatcher(SizesToPick...)() is not visible from module std_uni
generated/linux/release/64/publictests/std_uni.d(250): Deprecation: std.uni.Utf16Matcher!().Impl!(1, 2).Impl.subMatcher(SizesToPick...)() is not visible from module std_uni
Yep, I think undocumenting them is the way to go for now. If the examples are not actually usable by users, then it's misleading to even show them. CI will prevent adding documented unittests that aren't usable outside the module, right? |
Yup. Any idea on how we could tackle the deprecation warnings for Windows? Maybe |
|
Correct me if I'm wrong, but couldn't those uses simply be replaced with |
Let's see what the auto-tester says ;-) |
Continuing to show the examples makes it easier for folks to figure out how the functions work so that they can more easily figure out how to fix their code so that it's not using the deprecated functions anymore - especially in cases where we're not providing a simple replacement (as is the case here). So, I think that it's better to keep the examples in the documentation if we can. |
In this particular case the problem was that the examples were using private symbols, so the examples were To see for yourself, copy one of the unittests undocumented here to a new D file and try to compile them. E.g.: import std.uni;
void main()
{
auto m = utfMatcher!char(unicode.Number);
string square = "2²";
// about sub-matchers
assert(!m.subMatcher!(2,3,4).test(square)); // ASCII no covered
assert(m.subMatcher!1.match(square)); // ASCII-only, works
assert(!m.subMatcher!1.test(square)); // unicode '²'
assert(m.subMatcher!(2,3,4).match(square)); //
assert(square == "");
wstring wsquare = "2²";
auto m16 = utfMatcher!wchar(unicode.Number);
// may keep ref, but the orignal (m16) must be kept alive
auto bmp = m16.subMatcher!1;
assert(bmp.match(wsquare)); // Okay, in basic multilingual plan
assert(bmp.match(wsquare)); // And '²' too
}This gives deprecation warnings because |
|
Ah, okay. That makes sense then. |
Did github not let you provide an empty comment when dismissing your review? |
|
Exactomundo. |
|
Some remaining ones (from the autotester): |
| private import std.conv; | ||
| private import std.string; | ||
| private import std.utf; | ||
| private import std.windows.syserror; |
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.
Btw what's the reason for private imports? Aren't they private by default?
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 think very very old versions of D (well into 0.x) had imports public by default, like C header files.
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.
Wow -> #5553
4408b6d to
d895932
Compare
|
LGTM. @DmitryOlshansky Please have a look at the std.uni unit tests when you find the time. |
|
Pardon me but why did you ( @wilzbach @CyberShadow @jmdavis ) make and/or accept this completely stupid thing ? Now when the goal of a DMD pull request is to deprecate something everything goes red and the auto tester cant be used anymore to fix the PR (e.g platform specific failure missed locally) because the tests don't run anymore. see the tests here dlang/dmd#6925 👏 |
That's exactly why we made this PRs in case you haven't noticed as there have been continuous incidents (aka regressions) of deprecations within Phobos showing up in the user build due to Posix being the most popular developer platform. See also: #5083 (comment) |
|
But it can't work. Phobos and DMD are two different repositories ! |
|
I wholeheartedly agree with @bbasile here, but for different reason. If you have code which have a certain behavior, and you want to deprecate one symbol, but keep the same behavior, there are places where you have no choices but to use a deprecated symbol. One example which happened recently is here. I ended up using a hack with |
I suggest to wait until we run into a situation that warrants reconsidering this before reverting it.
Why not:
|
It will work, but you are basically duplicating all your public symbols, as you need to do it for everything you are deprecating. It feels very wrong that you have to do such a large patchset for a simple deprecation. But yes, it's possible if you are willing to go through that pain. |
|
I don't know; it seems more wrong to me to be hypocritical about deprecations. If you absolutely need to use public symbols from inside your implementations so much that deprecating such public symbols becomes an issue, it may indicate that there is a problem with the separation of interface and implementation in your code base. Futhermore, projects that wish to use the Anyway, the requirements and internal structure of Ocean and Phobos are undoubtedly very different, so I suggest to wait and see if/when we run into an actual problem. |
|
@mathias-lang-sociomantic I don't understand your reaction. What's the problem with making deprecations errors inside Phobos? How does this effect anyone else? Of course, if we reach a place where this is a problem, this could easily be disabled, but for the time being, I believe that the more rigorous testing is well worth it. @bbasile what's the problem with fixing the errors caused by deprecations first and then merging PRs that actually introduce those deprecations? Either way, the hardest thing is getting the proposal to deprecate something accepted rather than fixing the stuff themselves, IMO (though your specific case is a bit more involved because people were casting string literals to static arrays). |
|
Case in point: |

#5083 (comment)
CC @CyberShadow