Skip to content

Commit afb4bde

Browse files
committed
aaaaaaa
1 parent 970f65f commit afb4bde

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

source/stackCheck.d

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,25 @@ class StackChecker {
162162
foreach (i, ref cond ; node.condition) {
163163
auto oldStack = stack.dup;
164164

165+
Node conditionNode = node.condition.empty()? node : cond[$ - 1];
166+
165167
Evaluate(cond);
168+
Pop(conditionNode, 1);
166169
Evaluate(node.doIf[i]);
167170

168-
if (i == 0) {
171+
if ((i == 0) && !node.hasElse) {
169172
blockStack = stack.length;
170173
}
171174
else if (stack.length != blockStack) {
172-
ErrorInfo error = node.doIf[i].empty()?
173-
node.error : node.doIf[i][$ - 1].error;
175+
Node errorNode = node.doIf[i].empty()?
176+
node : node.doIf[i][$ - 1];
177+
178+
Note(errorNode.error, "Expected stack length '%d', got '%d'", blockStack, stack.length);
179+
Error(errorNode.error, "If statement has inconsistent stack effects");
174180

175-
Error(error, "If statement has inconsistent stack effects");
181+
if (stack.length > blockStack) {
182+
StackOverflow(errorNode, blockStack);
183+
}
176184
}
177185

178186
stack = oldStack;

0 commit comments

Comments
 (0)