Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix issue 9289: Show deprecations even when gag is on #1581

Closed
wants to merge 1 commit into from

2 participants

@leandro-lucarella-sociomantic

Deprecations warnings should be shown everywhere, because if you are
using any deprecated features (even in traits or static ifs) you
should be noticed.

This pull request will pass the test suite only when pull #1579 is merged.

I can update this if pull #1579 doesn't get accepted but this one does.

@leandro-lucarella-sociomantic leandro-lucarella-sociomantic Fix issue 9289: Show deprecations even when gag is on
Deprecations warnings should be shown everywhere, because if you are
using *any* deprecated features (even in traits or static ifs) you
should be noticed.
70f9378
@leandro-lucarella-sociomantic

OK, looks like pulling #1579 is not strictly necessary but the added testcase will have no effect in this case.

@don-clugston-sociomantic

Although this idea is appealing in some circumstances (specifically, when you have just upgraded from one compiler version to another), in others it is NOT what you want, and it breaks existing code.
Using your test case, suppose you have the code:

auto  foo(P)(P p){
    static if ( is(typeof( *p)) {
        return *p;
    } else static if (is(typeof(p[0])) {
       return p[0];
    } else static assert(0, "unsupported");
}

Currently, if -d is not specified, passing an array to this will work correctly: the second return will be used. If -d is specified, it will also work correctly: the first return will be used. With your patch, the code will not work at all.
If I have a codebase where I never even use -d, this pull request is suddenly making that obscure, stupid, long-deprecated feature have an impact on my code!

I think we just have to accept that having deprecated features still accepted in the language is a major annoyance. I'm not sure that there is a perfect solution. We should really try to get rid of them.

@leandro-lucarella-sociomantic

@donc Please, try to make comments only to the submitted patch (code) here, not the solution itself. The rationale behind this patch is in the bugzilla issue, if you see problems with the solution is better to reply there, otherwise the conversation will be lost if this pull request is closed and need more discussion about the solution to pick.

I'll copy your message there and reply there too:
http://d.puremagic.com/issues/show_bug.cgi?id=9289

@leandro-lucarella-sociomantic

Looks like this pull request doesn't really fix the problem...

@leandro-lucarella-sociomantic leandro-lucarella-sociomantic deleted the leandro-lucarella-sociomantic:depregag branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 29, 2013
  1. @leandro-lucarella-sociomantic

    Fix issue 9289: Show deprecations even when gag is on

    leandro-lucarella-sociomantic authored
    Deprecations warnings should be shown everywhere, because if you are
    using *any* deprecated features (even in traits or static ifs) you
    should be noticed.
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 1 deletion.
  1. +1 −1  src/mars.c
  2. +14 −0 test/runnable/depregag.d
View
2  src/mars.c
@@ -269,7 +269,7 @@ void vdeprecation(Loc loc, const char *format, va_list ap,
static const char *header = "Deprecation: ";
if (global.params.useDeprecated == 0)
verror(loc, format, ap, p1, p2, header);
- else if (global.params.useDeprecated == 2 && !global.gag)
+ else if (global.params.useDeprecated == 2)
verrorPrint(loc, header, format, ap, p1, p2);
}
View
14 test/runnable/depregag.d
@@ -0,0 +1,14 @@
+// PERMUTE_ARGS: -dw
+/* COMPILE_OUTPUT:
+---
+runnable/depregag.d(10): Deprecation: using * on an array is deprecated; use *(arr).ptr instead
+---
+*/
+extern (C) int printf(char* msg, ...);
+void main() {
+ int[] arr;
+ static if (is(typeof({ auto ptr = *arr; })))
+ printf("*arr is still valid even if deprecated\n".dup.ptr);
+ else
+ assert(0, "*arr is not longer supported");
+}
Something went wrong with that request. Please try again.