Fix parsing of nested ternary
This commit is contained in:
parent
3c8855ddcf
commit
6fee62f341
@ -2394,7 +2394,7 @@ static void actualTernary(size_t count, KrkScanner oldScanner, Parser oldParser)
|
||||
emitByte(OP_POP); /* Pop the condition */
|
||||
consume(TOKEN_ELSE, "Expected 'else' after ternary condition");
|
||||
|
||||
parsePrecedence(PREC_OR);
|
||||
parsePrecedence(PREC_TERNARY);
|
||||
|
||||
KrkScanner outScanner = krk_tellScanner();
|
||||
Parser outParser = parser;
|
||||
|
5
test/testNestedTernary.krk
Normal file
5
test/testNestedTernary.krk
Normal file
@ -0,0 +1,5 @@
|
||||
print('a' if False else 'b' if False else 'c')
|
||||
print('a' if False else 'b' if True else 'c')
|
||||
print('a' if True else 'b' if False else 'c')
|
||||
print('a' if True else 'b' if True else 'c')
|
||||
|
4
test/testNestedTernary.krk.expect
Normal file
4
test/testNestedTernary.krk.expect
Normal file
@ -0,0 +1,4 @@
|
||||
c
|
||||
b
|
||||
a
|
||||
a
|
Loading…
Reference in New Issue
Block a user