summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-01-13 14:59:58 +0100
committerAraq <rumpf_a@web.de>2012-01-13 14:59:58 +0100
commitc682a1da2b4f364718aaa5e895885043a6f7b873 (patch)
tree6053db32966b60ed67584993a201244ee229a8c1 /compiler
parente362cbbfd79f5b95ad0c7a218a3f7a35d91edbf7 (diff)
downloadNim-c682a1da2b4f364718aaa5e895885043a6f7b873.tar.gz
bugfix: invalid indentation for 'else' is detected; optional indentation for 'if' expressions
Diffstat (limited to 'compiler')
-rwxr-xr-xcompiler/ast.nim2
-rwxr-xr-xcompiler/parser.nim7
2 files changed, 7 insertions, 2 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index b936ec3b4..9e799e051 100755
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -1024,7 +1024,7 @@ proc getStrOrChar*(a: PNode): string =
 
 proc isGenericRoutine*(s: PSym): bool = 
   case s.kind
-  of skProc, skTemplate, skMacro, skIterator:
+  of skProc, skTemplate, skMacro, skIterator, skMethod:
     result = s.ast != nil and s.ast[genericParamsPos].kind != nkEmpty
   else: nil
 
diff --git a/compiler/parser.nim b/compiler/parser.nim
index acca5feaf..a0d8ad44a 100755
--- a/compiler/parser.nim
+++ b/compiler/parser.nim
@@ -503,12 +503,15 @@ proc parseIfExpr(p: var TParser): PNode =
     var branch = newNodeP(nkElifExpr, p)
     addSon(branch, parseExpr(p))
     eat(p, tkColon)
+    optInd(p, branch)
     addSon(branch, parseExpr(p))
+    optInd(p, branch)
     addSon(result, branch)
     if p.tok.tokType != tkElif: break 
   var branch = newNodeP(nkElseExpr, p)
   eat(p, tkElse)
   eat(p, tkColon)
+  optInd(p, branch)
   addSon(branch, parseExpr(p))
   addSon(result, branch)
 
@@ -1368,7 +1371,9 @@ proc parseStmt(p: var TParser): PNode =
         break 
       else: 
         var a = complexOrSimpleStmt(p)
-        if a.kind == nkEmpty: break 
+        if a.kind == nkEmpty:
+          parMessage(p, errInvalidIndentation)
+          break 
         addSon(result, a)
     popInd(p.lex)
   else: