www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9960] New: Show warnings/deprecations during template instantiation

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9960

           Summary: Show warnings/deprecations during template
                    instantiation
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: lio+bugzilla lunesu.com


--- Comment #0 from Lionello Lunesu <lio+bugzilla lunesu.com> 2013-04-18
21:15:28 PDT ---
We should show warnings (when enabled) and deprecations (when allowed = not an
error) during successful(!) template instantiations.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 18 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9960



--- Comment #1 from Lionello Lunesu <lio+bugzilla lunesu.com> 2013-04-18
22:16:58 PDT ---
The reason this needs to be fixed is that's it's too hard to track down errors
in templates, since they simply won't get instantiated on error and the only
message will be "errors instantiating template".

Showing errors during template instantiation is not useful, since there will be
too many, and no notion of "successful" instantiation.

Printing the warnings/deprecations on successful instantiation is probably
tricky because you won't know whether it's successful until much later, and
even then I suppose a particular instantiation might be picked from several
successful ones.

Perhaps it would be sufficient to show warnings/deprecations in verbose mode
only?

Proposal:

-w      no change
-w -v   shows warnings during template instantiation
-wi -v  shows warnings during template instantiation (no linking iff >0)
-d      no change
-d -v   no change
-v      shows deprecation warnings during template instantiation
-dw -v  shows deprecation warnings during template instantiation
-de -v  shows deprecations as errors during template instantiation

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 18 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9960



--- Comment #2 from Lionello Lunesu <lio+bugzilla lunesu.com> 2013-04-19
00:04:55 PDT ---
The highest priority would be to solve the case when deprecations are reported
as errors. This case currently prevents a template instantiation and swallows
the deprecation message, only showing the final instantiation failure. A
template that would otherwise get picked will suddenly not be considered,
without any further information. 

In fact, a different template might get picked with "-de" compared to the
default "-dw" so we shouldn't ever gag deprecation errors during template
instantiation, no matter whether "-v" was specified or not.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 19 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9960



--- Comment #3 from Don <clugdbug yahoo.com.au> 2013-04-22 01:29:25 PDT ---
 In fact, a different template might get picked with "-de" compared to the
default "-dw" so we shouldn't ever gag deprecation errors during template instantiation, no matter whether "-v" was specified or not. This is incorrect, it would remove the possibility of compiling without deprecated features, which is the most important and common case! This would break existing code, and worse, would give no way to fix it. It's actually a difficult problem. What's needed instead, I think, is a flag for "tell me which recently deprecated features I'm still using." Suppose feature F7 is deprecated in release 7, and feature F9 is deprecated in release 9. Initially your code contains F7 and F9. When release 7 is released, you fix your code so that it no longer uses F7. Once you've done this, you never want to hear a warning about F7 again, you want to act as if it had never existed in the language. Then, release 9 happens. Now, you want to know when you are using feature F9. You actually don't care about F7 any more. The point is -- you only care about the use of deprecated features *while you are in the process of removing them*. The compiler should be silent except in that case. The only possibility I can see is a compiler to flag to tell the compiler that this is what you're doing. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9960



--- Comment #4 from Lionello Lunesu <lio+bugzilla lunesu.com> 2013-04-23
01:39:56 PDT ---
(In reply to comment #3)
 In fact, a different template might get picked with "-de" compared to the
default "-dw" so we shouldn't ever gag deprecation errors during template instantiation, no matter whether "-v" was specified or not. This is incorrect, it would remove the possibility of compiling without deprecated features, which is the most important and common case!
You can still do that, but you'd see the deprecation errors, which are not fatal, but will cause that particular template instantiation to be skipped.
 This would break existing code, and worse, would give no way to fix it.
The only change is that with "-de" it would _print_ the deprecation errors. Deprecation errors are already errors and cause template substitutions to fail.
 It's actually a difficult problem. What's needed instead, I think, is a flag
 for "tell me which recently deprecated features I'm still using."
I get your point, but I honestly think there's something dangerous about getting different code with -dw compared to -de. I'd expect compilation to fail if there are deprecating being used, no matter whether those features are used within templates or not. (Heck, in D practically everything is a template nowadays, so this point is even more important.) Therefor I think it's perfectly valid to _PRINT_ deprecation errors as they happen, since you've flagged them as errors and that's what they are. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 23 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9960



--- Comment #5 from Lionello Lunesu <lio+bugzilla lunesu.com> 2013-05-01
07:30:42 PDT ---
I've changed the pull request to only print deprecation errors during
instantiation when in verbose -v mode. 

I still have mixed feelings about the having different templates apply when
using -dw versus -de, but assuming that you actually want this behavior, now
adding -v lets you see which templates got skipped.

https://github.com/D-Programming-Language/dmd/pull/1912

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 01 2013