Fix a bad indentation handling for if/try.
This commit is contained in:
parent
fe737255ba
commit
f97d8cd562
@ -1282,14 +1282,14 @@ static void ifStatement() {
|
|||||||
block(blockWidth,"else");
|
block(blockWidth,"else");
|
||||||
endScope();
|
endScope();
|
||||||
}
|
}
|
||||||
} else {
|
} else if (!check(TOKEN_EOF) && !check(TOKEN_EOL)) {
|
||||||
if (!check(TOKEN_EOF) && !check(TOKEN_EOL)) {
|
|
||||||
krk_ungetToken(parser.current);
|
krk_ungetToken(parser.current);
|
||||||
parser.current = parser.previous;
|
parser.current = parser.previous;
|
||||||
if (blockWidth) {
|
if (blockWidth) {
|
||||||
parser.previous = previous;
|
parser.previous = previous;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
advance(); /* Ignore this blank indentation line */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1519,6 +1519,8 @@ static void tryStatement() {
|
|||||||
if (blockWidth) {
|
if (blockWidth) {
|
||||||
parser.previous = previous;
|
parser.previous = previous;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
advance(); /* Ignore this blank indentation line */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
17
test/testWeirdIndentCase.krk
Normal file
17
test/testWeirdIndentCase.krk
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
def test(val):
|
||||||
|
if val:
|
||||||
|
print("In if")
|
||||||
|
# Comment
|
||||||
|
# val -= int(val / max) * max
|
||||||
|
return val
|
||||||
|
|
||||||
|
print("Result:", test(True))
|
||||||
|
print("result:", test(False))
|
||||||
|
|
||||||
|
def test2(val):
|
||||||
|
try:
|
||||||
|
print("This has a comment on the next line.", val)
|
||||||
|
# That could have been an else.
|
||||||
|
return val
|
||||||
|
|
||||||
|
print("Result:", test2(True))
|
5
test/testWeirdIndentCase.krk.expect
Normal file
5
test/testWeirdIndentCase.krk.expect
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
In if
|
||||||
|
Result: True
|
||||||
|
result: False
|
||||||
|
This has a comment on the next line. True
|
||||||
|
Result: True
|
Loading…
Reference in New Issue
Block a user