Warn about do nothing expressions?
Justin Whear
justin at economicmodeling.com
Mon Mar 31 09:20:26 PDT 2014
On Mon, 31 Mar 2014 16:07:25 +0000, monarch_dodra wrote:
>
> The issue is that the legality of this can't be checked at the semantic
> phase.
>
> It depends on *who* the left and right hand sides are. It's obvious in
> "i = i++;", but if you start mixing function calls, references and
> whatnot, the line becomes more blurry:
>
> //----
> int i;
> auto p = &i;
> *p = i++; //Legal? Illegal?
> //----
>
> So this means making it illegal is out of the question.
>
> As for making it a warning, well, Walter is (AFAIK) pretty much against
> having any warnings at all, short of straight up deterministic semantic
> warnings "dangling else"/"deprecation".
Yeah, I understand that detecting anything more than the very simplest
cases may be impossible--I'm thinking of an error similar to the existing
"var has no effect in expression" which has helped me catch typos and
simple mistakes.
Justin
More information about the Digitalmars-d
mailing list