Closed jvasileff closed 8 years ago
Ugh.
The expression following
then
orelse
is parsed with precedence just higher than the||
operator, and just lower than thethen
andelse
operators, that is, between the layers 3 and 4 defined in §6.8.1 Operator precedence.
Why is this tucked away in §6.7.1 if/then/else
expressions and not mentioned at all in §6.8.1?
I guess this means I’ll have to add an alias between DisjoiningExpression
and ThenElseExpression
.
The alias will include IfElseExpression
, SwitchCaseElseExpression
, LetExpression
, and of course DisjoiningExpression
, and be called…?
…StructureExpression
, unless I can come up with something better.
Hm, this also means that this is no longer correct:
shared abstract class BinaryOperation()
of …
extends Operation() {
"The left operand."
shared formal ValueExpression leftOperand;
"The right operand."
shared formal ValueExpression rightOperand;
shared actual formal [ValueExpression, ValueExpression] children;
}
since IfTheExpression
and friends aren’t ValueExpression
s.
Why is this tucked away in §6.7.1
if/then/else
expressions and not mentioned at all in §6.8.1?
Because these aren't operators?
That table is mainly about precedence IMO, and these constructs also have precedence.
The typchecker allows:
but ceylon.ast fails with:
for the tree
The code
i = if (true) then 1 else 1;
does compile.