From 1881fc5812aeada551e32c0d81a3aa4f6fceb0bb Mon Sep 17 00:00:00 2001 From: Clyybber Date: Sat, 12 Sep 2020 13:39:46 +0200 Subject: [PATCH] Fix #15305 (#15311) * Fix #15305 * Fix test --- compiler/parser.nim | 3 +-- tests/parser/tifexprs.nim | 12 ++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 tests/parser/tifexprs.nim diff --git a/compiler/parser.nim b/compiler/parser.nim index f256cee66c..17dd092a4a 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -2242,8 +2242,7 @@ proc parseStmt(p: var Parser): PNode = break p.hasProgress = false if p.tok.tokType in {tkElse, tkElif}: - parMessage(p, errInvalidIndentation) - getTok(p) + break # Allow this too, see tests/parser/tifexprs result.add complexOrSimpleStmt(p) if not p.hasProgress and p.tok.tokType == tkEof: break diff --git a/tests/parser/tifexprs.nim b/tests/parser/tifexprs.nim new file mode 100644 index 0000000000..3a7e2bddc6 --- /dev/null +++ b/tests/parser/tifexprs.nim @@ -0,0 +1,12 @@ +discard """ + output: ''' +1 +''' +""" + +var a, b: int +let x = if a > b: + 0 + else: 1 + +echo x