Fix incorrect handling of blank and comment lines before 'else', 'except', etc.
This commit is contained in:
parent
c1f2c7d9f3
commit
e24ea3d32c
@ -97,9 +97,10 @@ static KrkToken makeIndentation() {
|
||||
}
|
||||
KrkToken out = makeToken(TOKEN_INDENTATION);
|
||||
if (reject == ' ') out.length *= 8;
|
||||
if (peek() == '#') {
|
||||
/* Skip the entirety of the comment but not the line feed */
|
||||
if (peek() == '#' || peek() == '\n') {
|
||||
while (!isAtEnd() && peek() != '\n') advance();
|
||||
scanner.startOfLine = 1;
|
||||
return makeToken(TOKEN_RETRY);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
28
test/testEmptyIndentedLine.krk
Normal file
28
test/testEmptyIndentedLine.krk
Normal file
@ -0,0 +1,28 @@
|
||||
if True:
|
||||
if False:
|
||||
print("fail")
|
||||
|
||||
else:
|
||||
print("pass")
|
||||
|
||||
if True:
|
||||
if False:
|
||||
print("fail")
|
||||
# test
|
||||
else:
|
||||
print("pass")
|
||||
|
||||
if True:
|
||||
if False:
|
||||
print("fail")
|
||||
# test
|
||||
else:
|
||||
print("pass")
|
||||
|
||||
if True:
|
||||
if False:
|
||||
print("fail")
|
||||
|
||||
#test
|
||||
else:
|
||||
print("pass")
|
4
test/testEmptyIndentedLine.krk.expect
Normal file
4
test/testEmptyIndentedLine.krk.expect
Normal file
@ -0,0 +1,4 @@
|
||||
pass
|
||||
pass
|
||||
pass
|
||||
pass
|
Loading…
Reference in New Issue
Block a user