diff options
author | Clyybber <darkmine956@gmail.com> | 2020-09-12 13:39:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-12 12:39:46 +0100 |
commit | 1881fc5812aeada551e32c0d81a3aa4f6fceb0bb (patch) | |
tree | f266bded69b96dcc5fd73ce24a2a8b9ab4873c30 | |
parent | a41b243fea007b9aec8da0e950aa3368777aab37 (diff) | |
download | Nim-1881fc5812aeada551e32c0d81a3aa4f6fceb0bb.tar.gz |
Fix #15305 (#15311)
* Fix #15305 * Fix test
-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 |