D Logic bug

krzaq dlangmailinglist at krzaq.cc
Thu Oct 11 17:11:40 UTC 2018


On Thursday, 11 October 2018 at 14:35:34 UTC, James Japherson 
wrote:
> Took me about an hour to track this one down!
>
> A + (B == 0) ? 0 : C;
>
> D is evaluating it as
>
> (A + (B == 0)) ? 0 : C;
>
>
> The whole point of the parenthesis was to associate.
>
> I usually explicitly associate precisely because of this!
>
> A + ((B == 0) ? 0 : C);
>
> In the ternary operator it should treat parenthesis directly to 
> the left as the argument.
>
> Of course, I doubt this will get fixed but it should be noted 
> so other don't step in the same poo.

Are any languages evaluating it differently? For example, is this 
different from C, C++, Java, C#, Ruby, Javascript?


More information about the Digitalmars-d mailing list