bug in grammar with ?:

ketmar ketmar at ketmar.no-ip.org
Tue Sep 17 18:06:55 UTC 2019


Brett wrote:

> Fails(loop is not taken):
>
> for(ulong i = len - 1; i >= (true) ? 0 : 1; i--)
>
>
> passes
>
> for(ulong i = len - 1; i >= ((true) ? 0 : 1); i--)
>
> Only difference is parenthesis(yes, that is all, doesn't matter if it's 
> true or false)

not a bug. the whole thing before `?` is a condition, so

	i >= (true) ? 0 : 1

returns 0, of course, because `i >= 1` (your `len` is obviously >= 1), and 
the result of the expression is therefor 0.


More information about the Digitalmars-d mailing list