summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-07-26 08:47:54 +0200
committerAraq <rumpf_a@web.de>2012-07-26 08:47:54 +0200
commit2ff8d17369eff133292009acd0866aa32d2912d0 (patch)
tree9f2ae44d6c74f188778f410172edfd9cddd6a27c
parent9222a8a0ebe36ae3086d5a385650778b6c4d1e16 (diff)
downloadNim-2ff8d17369eff133292009acd0866aa32d2912d0.tar.gz
added warning for confusing var declarations
-rwxr-xr-xcompiler/docgen.nim4
-rwxr-xr-xcompiler/msgs.nim7
-rwxr-xr-xcompiler/semstmts.nim3
-rwxr-xr-xcompiler/transf.nim11
-rwxr-xr-xtodo.txt1
5 files changed, 19 insertions, 7 deletions
diff --git a/compiler/docgen.nim b/compiler/docgen.nim
index 629826339..6fe1d03b1 100755
--- a/compiler/docgen.nim
+++ b/compiler/docgen.nim
@@ -284,8 +284,8 @@ proc genSection(d: PDoc, kind: TSymKind) =
       ord(kind).toRope, title, toRope(ord(kind) + 50), d.toc[kind]])
 
 proc genOutFile(d: PDoc): PRope = 
-  var 
-    code, content: PRope = nil
+  var
+    code, content: PRope
     title = ""
   var j = 0
   var tmp = ""
diff --git a/compiler/msgs.nim b/compiler/msgs.nim
index 30066d376..de29a4a40 100755
--- a/compiler/msgs.nim
+++ b/compiler/msgs.nim
@@ -103,7 +103,7 @@ type
     warnUnknownSubstitutionX, warnLanguageXNotSupported, warnCommentXIgnored, 
     warnXisPassedToProcVar, warnAnalysisLoophole,
     warnDifferentHeaps, warnWriteToForeignHeap, warnImplicitClosure,
-    warnUser, 
+    warnEachIdentIsTuple, warnUser,
     hintSuccess, hintSuccessX, 
     hintLineTooLong, hintXDeclaredButNotUsed, hintConvToBaseNotNeeded, 
     hintConvFromXtoItselfNotNeeded, hintExprAlwaysX, hintQuitCalled, 
@@ -346,6 +346,7 @@ const
     warnDifferentHeaps: "possible inconsistency of thread local heaps [DifferentHeaps]",
     warnWriteToForeignHeap: "write to foreign heap [WriteToForeignHeap]",
     warnImplicitClosure: "implicit closure convention: '$1' [ImplicitClosure]",
+    warnEachIdentIsTuple: "each identifier is a tuple [EachIdentIsTuple]",
     warnUser: "$1 [User]", 
     hintSuccess: "operation successful [Success]", 
     hintSuccessX: "operation successful ($# lines compiled; $# sec total; $#) [SuccessX]", 
@@ -363,14 +364,14 @@ const
     hintUser: "$1 [User]"]
 
 const
-  WarningsToStr*: array[0..17, string] = ["CannotOpenFile", "OctalEscape", 
+  WarningsToStr*: array[0..18, string] = ["CannotOpenFile", "OctalEscape", 
     "XIsNeverRead", "XmightNotBeenInit",
     "Deprecated", "ConfigDeprecated",
     "SmallLshouldNotBeUsed", "UnknownMagic", 
     "RedefinitionOfLabel", "UnknownSubstitutionX", "LanguageXNotSupported", 
     "CommentXIgnored", "XisPassedToProcVar",
     "AnalysisLoophole", "DifferentHeaps", "WriteToForeignHeap",
-    "ImplicitClosure,", "User"]
+    "ImplicitClosure", "EachIdentIsTuple", "User"]
 
   HintsToStr*: array[0..13, string] = ["Success", "SuccessX", "LineTooLong", 
     "XDeclaredButNotUsed", "ConvToBaseNotNeeded", "ConvFromXtoItselfNotNeeded", 
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 0c727b1a5..7b1c6d76a 100755
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -270,6 +270,9 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
       b.sons[length-2] = a.sons[length-2] # keep type desc for doc generator
       b.sons[length-1] = def
       addSon(result, b)
+    elif tup.kind == tyTuple and def.kind == nkPar and 
+        a.kind == nkIdentDefs and a.len > 3:
+      Message(a.info, warnEachIdentIsTuple)
     for j in countup(0, length-3):
       var v = semIdentDef(c, a.sons[j], symkind)
       addInterfaceDecl(c, v)
diff --git a/compiler/transf.nim b/compiler/transf.nim
index 4e799a11f..284958e77 100755
--- a/compiler/transf.nim
+++ b/compiler/transf.nim
@@ -244,7 +244,16 @@ proc transformConstSection(c: PTransf, v: PNode): PTransNode =
         result[i] = PTransNode(b)
       else:
         result[i] = PTransNode(it)
-  
+
+proc trivialBody(s: PSym): PNode =
+  # a routine's body is trivially inlinable if marked as 'inline' and its
+  # body consists of only 1 statement. It is important that we perform this
+  # optimization here as 'distinct strings' may cause string copying otherwise:
+  # proc xml(s: string): TXmlString = return xmlstring(s)
+  # We have to generate a ``nkLineTracking`` node though to not lose
+  # debug information:
+  # XXX to implement
+  nil
 
 proc hasContinue(n: PNode): bool = 
   case n.kind
diff --git a/todo.txt b/todo.txt
index d145f15b6..2668945fa 100755
--- a/todo.txt
+++ b/todo.txt
@@ -4,7 +4,6 @@ version 0.9.0
 - closure: implement closure support for procs capturing nested
   module vars
 - implicit deref for parameter matching
-- deprecate ``var x, y = 0`` as it's confusing for tuple consistency
 
 - ``borrow`` needs to take type classes into account
 - ``=`` should be overloadable; requires specialization for ``=``