diff options
-rw-r--r-- | compiler/parser.nim | 3 | ||||
-rw-r--r-- | tests/parser/tifexprs.nim | 12 |
2 files changed, 13 insertions, 2 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index f256cee66..17dd092a4 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 000000000..3a7e2bddc --- /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 |