summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rwxr-xr-xcompiler/docgen.nim4
-rw-r--r--compiler/docgen2.nim8
-rwxr-xr-xcompiler/ropes.nim10
-rwxr-xr-xcompiler/semstmts.nim4
-rwxr-xr-xcompiler/semtypes.nim2
-rwxr-xr-xcompiler/transf.nim5
6 files changed, 20 insertions, 13 deletions
diff --git a/compiler/docgen.nim b/compiler/docgen.nim
index 69e61db99..629826339 100755
--- a/compiler/docgen.nim
+++ b/compiler/docgen.nim
@@ -322,12 +322,12 @@ proc generateIndex*(d: PDoc) =
     writeIndexFile(d[], splitFile(options.outFile).dir / 
                         splitFile(d.filename).name & indexExt)
 
-proc writeOutput*(d: PDoc, filename, outExt: string) = 
+proc writeOutput*(d: PDoc, filename, outExt: string, useWarning = false) = 
   var content = genOutFile(d)
   if optStdout in gGlobalOptions:
     writeRope(stdout, content)
   else:
-    writeRope(content, getOutFile(filename, outExt))
+    writeRope(content, getOutFile(filename, outExt), useWarning)
 
 proc CommandDoc*() =
   var ast = parseFile(addFileExt(gProjectFull, nimExt))
diff --git a/compiler/docgen2.nim b/compiler/docgen2.nim
index a7a84641e..ba3f5d4ca 100644
--- a/compiler/docgen2.nim
+++ b/compiler/docgen2.nim
@@ -22,8 +22,12 @@ type
 
 proc close(p: PPassContext, n: PNode): PNode =
   var g = PGen(p)
-  writeOutput(g.doc, g.filename, HtmlExt)
-  generateIndex(g.doc)
+  let useWarning = sfMainModule notin g.module.flags
+  writeOutput(g.doc, g.filename, HtmlExt, useWarning)
+  try:
+    generateIndex(g.doc)
+  except EIO:
+    nil
 
 proc processNode(c: PPassContext, n: PNode): PNode = 
   result = n
diff --git a/compiler/ropes.nim b/compiler/ropes.nim
index 31ec29f0a..545e27b41 100755
--- a/compiler/ropes.nim
+++ b/compiler/ropes.nim
@@ -82,7 +82,6 @@ proc prepend*(a: var PRope, b: PRope)
 proc toRope*(s: string): PRope
 proc toRope*(i: BiggestInt): PRope
 proc ropeLen*(a: PRope): int
-proc WriteRope*(head: PRope, filename: string)
 proc writeRopeIfNotEqual*(r: PRope, filename: string): bool
 proc ropeToStr*(p: PRope): string
 proc ropef*(frmt: TFormatStr, args: openarray[PRope]): PRope
@@ -204,13 +203,14 @@ proc writeRope*(f: TFile, c: PRope) =
     assert(it.data != nil)
     write(f, it.data)
 
-proc WriteRope(head: PRope, filename: string) = 
+proc WriteRope*(head: PRope, filename: string, useWarning = false) =
   var f: tfile
-  if open(f, filename, fmWrite): 
+  if open(f, filename, fmWrite):
     if head != nil: WriteRope(f, head)
     close(f)
-  else: 
-    rawMessage(errCannotOpenFile, filename)
+  else:
+    rawMessage(if useWarning: warnCannotOpenFile else: errCannotOpenFile,
+               filename)
 
 proc ropef(frmt: TFormatStr, args: openarray[PRope]): PRope = 
   var i = 0
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index fd3ac7891..eb7660dd6 100755
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -267,7 +267,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
         GlobalError(a.info, errWrongNumberOfVariables)
       b = newNodeI(nkVarTuple, a.info)
       newSons(b, length)
-      b.sons[length-2] = ast.emptyNode # no type desc
+      b.sons[length-2] = a.sons[length-2] # keep type desc for doc generator
       b.sons[length-1] = def
       addSon(result, b)
     for j in countup(0, length-3):
@@ -286,7 +286,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
         v.typ = typ
         b = newNodeI(nkIdentDefs, a.info)
         addSon(b, newSymNode(v))
-        addSon(b, ast.emptyNode)        # no type description
+        addSon(b, a.sons[length-2])      # keep type desc for doc generator
         addSon(b, copyTree(def))
         addSon(result, b)
       else: 
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index 5e2e9e218..c437ce2b5 100755
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -897,7 +897,7 @@ proc semGenericParamList(c: PContext, n: PNode, father: PType = nil): PNode =
           s = newSymS(skType, a.sons[j], c)
           s.typ = newTypeS(tyGenericParam, c)
         of tyExpr:
-          echo "GENERIC EXPR ", a.info.toFileLineCol
+          #echo "GENERIC EXPR ", a.info.toFileLineCol
           # not a type param, but an expression
           # proc foo[x: expr](bar: int) what is this?
           s = newSymS(skGenericParam, a.sons[j], c)
diff --git a/compiler/transf.nim b/compiler/transf.nim
index c9e226c87..f6e87e828 100755
--- a/compiler/transf.nim
+++ b/compiler/transf.nim
@@ -703,8 +703,11 @@ proc transform(c: PTransf, n: PNode): PTransNode =
   of nkConstSection:
     # do not replace ``const c = 3`` with ``const 3 = 3``
     return transformConstSection(c, n)
+  of nkTypeSection:
+    # no need to transform type sections:
+    return PTransNode(n)
   of nkVarSection, nkLetSection:
-    if c.inlining > 0: 
+    if c.inlining > 0:
       # we need to copy the variables for multiple yield statements:
       result = transformVarSection(c, n)
     else: