From 7b7e2c56b7df43c7c6d99ef44dc4fff3b2e142bc Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Mon, 27 Jun 2022 12:19:27 -0700 Subject: [EH] Fix printing bug in nested blocks + delegate (#4753) `controlFlowDepth` is a variable used to print `delegate`'s target. When printing nested blocks, we increase `controlFlowDepth` by the number of nested blocks at once. But we should decrement it as we finish each block, rather than decrease by the number of nested blocks at once, because we need correct `controlFlowDepth` within nested blocks. --- src/passes/Print.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 7260d7161..2aacb513b 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2390,7 +2390,6 @@ struct PrintSExpression : public UnifiedExpressionVisitor { } } - int startControlFlowDepth = controlFlowDepth; controlFlowDepth += stack.size(); auto* top = stack.back(); while (stack.size() > 0) { @@ -2413,6 +2412,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor { } printFullLine(list[i]); } + controlFlowDepth--; } decIndent(); if (full) { @@ -2421,7 +2421,6 @@ struct PrintSExpression : public UnifiedExpressionVisitor { o << ' ' << curr->name; } } - controlFlowDepth = startControlFlowDepth; } void visitIf(If* curr) { controlFlowDepth++; -- cgit v1.2.3