[Issue 17424] Add useful warnings
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue May 23 18:30:33 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17424
Jonathan M Davis <issues.dlang at jmdavisProg.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |issues.dlang at jmdavisProg.co
| |m
--- Comment #2 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
(In reply to greenify from comment #1)
> Great idea. This is one of the areas where D is definitely behind other
> languages.
> IIRC Walter believes that the compiler isn't a linter, so if I am not
> mistaken only warnings with minimal or zero overhead will be merged.
His take on it is that warnings are a sign that folks couldn't agree on what
was right or wrong in the language. He tends to think that something should
either be an error or not (and I agree with him). But the issue of warnings has
been discussed many times in the newsgroup, and I really don't think that many
are going to be added to the compiler. And the fact that dmd stupidly has -w
makes them that much worse because of how that affects compile-time
introspection.
Ultimately though, the big problem with warnings is that if you're doing your
job right, you fix them all (if you don't, you just end up with a big pile of
warnings that get ignored and so you miss whatever value they do provide), and
so you might as well either make them errors or not warn about them at all. And
it gets _very_ annoying when the compiler warns about something that shouldn't
need to be changed. Really, anything that's going to be optional makes far more
sense in a linter.
I can certainly appreciate not wanting to compile your code twice (once to get
your executable and once to be told about potential - but not definite -
problems in your code), but IMHO, it really doesn't make sense for the compiler
to be warning about optional things. And I've never seen it be anything but a
disaster in practice with any other language. _Best_ case, you're stuck
"fixing" all kinds of stuff that isn't actually wrong so that you don't have
any warnings, but more often, you end up with tons of warnings that no one pays
attention to. Having at tool that can warn about potential problems has real
value, but I don't think that it's appropriate for the compiler to be doing it.
> Ideally
> Dscanner (https://github.com/dlang-community/D-Scanner) should be able to
> yield such warnings, but with it's current status as (a pure parser without
> any semantical analysis) many of your warnings will be hard to achieve.
> Hence, I guess the least controversial option is to introduce these warnings
> step by step with a new opt-in flag in the D fronted.
Walter is also very much against additional compiler flags. So, I think that
you're going to have a hard time convincing him that this is a good idea.
Having the compiler as a library as has been discussed would make it easier to
write a linter, but based on past discussions on this topic, I think that it's
pretty clear that the vast majority of these suggestions will never be compiler
warnings even if they make a lot of good sense for a linter.
--
More information about the Digitalmars-d-bugs
mailing list