The following code
void main(){
double a,b,c;
assert(a <>= b <>= c);
}
gets this response from the compiler
johang@klaffhorn:~$ dmd test.d
test.d(4): found '<>=' when expecting ')'
test.d(4): found 'c' when expecting ';' following 'statement'
test.d(4): found ')' instead of statement
johang@klaffhorn:~$
if parenthesis are added the problem disappear.
If this is not valid code the a more helpful error message would be nice.
Comment #1 by jarrett.billingsley — 2009-05-09T10:31:56Z
This is by design. Comparison operators cannot be chained like this. C accepts such foolishness as "a < b < c" even though it doesn't do what you'd expect (i.e. it doesn't evaluate to "a < b && b < c"). D changed all comparison operators to have the same precedence so that this kind of code would not be accepted, and for possible future expansion in which chained comparisons really would be converted into multiple clauses.
Comment #2 by lijat.me — 2009-05-09T20:05:53Z
In that case I think that a better error message would be needed. The current one left me confused about if it was a compiler bug or by design.
Comment #3 by jarrett.billingsley — 2009-05-09T20:46:58Z