void foo() { return 0; } this code gives main.d(24): Error: long has no effect in expression (0) iirc, it should be valid.
I'd actually like that to be the new behavior, as any other behavior (I tried them) caused worse problems. The good news is it's an easy fix for the code.
You should change the spec in this case: http://www.digitalmars.com/d/1.0/statement.html "Expression is allowed even if the function specifies a void return type. The Expression will be evaluated, but nothing will be returned."
fwiw, the new behavior makes sense to me.
(In reply to comment #2) > You should change the spec in this case: > > http://www.digitalmars.com/d/1.0/statement.html > > > "Expression is allowed even if the function specifies a void return type. The > Expression will be evaluated, but nothing will be returned." It's still true. This works, for example: void foo() { return bar(); } It's exactly the same as: { bar(); return; } which is OK. Likewise, return 0; becomes { 0; return; } which is generating the "no effect" error.
I'll change the spec to say that it's illegal to have a void return expression with no side effects.
Fixed dmd 2.037