visit block first because the condition variable may be initialized inside the block

This commit is contained in:
2020-03-09 23:04:55 +01:00
parent 36a38ee7ab
commit 5a5191612e

View File

@@ -150,8 +150,8 @@ public class ContextAnalysis extends KlangBaseVisitor<Node> {
@Override
public Node visitDoWhileLoop(KlangParser.DoWhileLoopContext ctx) {
Node condition = this.visit(ctx.cond);
Node block = this.visit(ctx.braced_block());
Node condition = this.visit(ctx.cond);
Node result = new DoWhileLoop((Expression) condition, (Block) block);
result.line = ctx.start.getLine();
result.col = ctx.start.getCharPositionInLine();