if (node.parent instanceof BlockScope)
{
node.setIfLastInScope(thisIndex == maxIndex - 1);
}
HaxeTree ifBlock = node.getIfBlock();
HaxeTree elseBlock = node.getElseBlock();
visit(ifBlock, declarations);
if (!node.isLastInScope())
{
node.setHaxeType(TypeUtils.getVoid());
return;
}
if (elseBlock == null)
{
// If there is no else, and the if expression is false,
// then the entire expression has type Void.
// TODO check for if expr is false and setting the type accordingly?
return;
}
visit(elseBlock, declarations);
HaxeType type = ifBlock.getHaxeType();
HaxeType elseType = elseBlock.getHaxeType();
if (elseType != null && elseType.equals(type))
{
// If there is an else, then expr-1 and expr-2 must be of the same type and
// this will be the type of the if expression
// TODO: maybe equals not the right part - available assignment?