D Logic bug

Patrick Schluter Patrick.Schluter at bbox.fr
Thu Oct 11 17:54:48 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;

As it should.

>
>
> 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.

No. Except for assignement and assignment operators, ternary 
operator has the lowest precedence of any operator in D (and C, 
C++, java, PHP, C# etc.).




More information about the Digitalmars-d mailing list