summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-03-21 09:34:02 +0100
committerAndreas Rumpf <rumpf_a@web.de>2019-03-21 09:34:02 +0100
commit83c105c3a33caf5e3158afdc540413e3795c159c (patch)
treeeb3139405db326a5b596f39e6497059a82e01d41
parent49c786331a4f7ef409437bd3c08202b5a5d73bed (diff)
parent48d5e4f95cc36f3f2dba1f21b66efad1882d5d27 (diff)
downloadNim-83c105c3a33caf5e3158afdc540413e3795c159c.tar.gz
Merge branch 'devel' of github.com:nim-lang/Nim into devel
-rw-r--r--compiler/ccgcalls.nim1
-rw-r--r--compiler/ccgexprs.nim2
-rw-r--r--compiler/ccgtypes.nim4
-rw-r--r--compiler/docgen.nim6
-rw-r--r--compiler/parser.nim5
-rw-r--r--compiler/renderer.nim10
-rw-r--r--compiler/vmdef.nim2
-rw-r--r--lib/impure/nre.nim2
-rw-r--r--lib/impure/re.nim7
-rw-r--r--lib/pure/os.nim9
-rw-r--r--lib/system/embedded.nim3
-rw-r--r--lib/system/excpt.nim11
-rw-r--r--lib/wrappers/pcre.nim2
-rw-r--r--nimdoc/testproject/expected/testproject.html2
-rw-r--r--tests/errmsgs/tcall_with_default_arg.nim18
-rw-r--r--tests/parser/tletcolon.nim16
16 files changed, 75 insertions, 25 deletions
diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim
index 4c8fa7147..cefa89289 100644
--- a/compiler/ccgcalls.nim
+++ b/compiler/ccgcalls.nim
@@ -20,6 +20,7 @@ proc hasNoInit(call: PNode): bool {.inline.} =
 
 proc fixupCall(p: BProc, le, ri: PNode, d: var TLoc,
                callee, params: Rope) =
+  genLineDir(p, ri)
   var pl = callee & ~"(" & params
   # getUniqueType() is too expensive here:
   var typ = skipTypes(ri.sons[0].typ, abstractInst)
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index 7de5e5606..28aa875bc 100644
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -2453,7 +2453,7 @@ proc expr(p: BProc, n: PNode, d: var TLoc) =
     putIntoDest(p, d, n, genLiteral(p, n))
   of nkCall, nkHiddenCallConv, nkInfix, nkPrefix, nkPostfix, nkCommand,
      nkCallStrLit:
-    genLineDir(p, n)
+    genLineDir(p, n) # may be redundant, it is generated in fixupCall as well
     let op = n.sons[0]
     if n.typ.isNil:
       # discard the value:
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index 51f04d076..f4864180e 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -246,8 +246,8 @@ proc cacheGetType(tab: TypeCache; sig: SigHash): Rope =
   result = tab.getOrDefault(sig)
 
 proc addAbiCheck(m: BModule, t: PType, name: Rope) =
-  if isDefined(m.config, "checkabi"):
-    addf(m.s[cfsTypeInfo], "NIM_CHECK_SIZE($1, $2);$n", [name, rope(getSize(m.config, t))])
+  if isDefined(m.config, "checkabi") and (let size = getSize(m.config, t); size != szUnknownSize):
+    addf(m.s[cfsTypeInfo], "NIM_CHECK_SIZE($1, $2);$n", [name, rope(size)])
 
 proc ccgIntroducedPtr(conf: ConfigRef; s: PSym): bool =
   var pt = skipTypes(s.typ, typedescInst)
diff --git a/compiler/docgen.nim b/compiler/docgen.nim
index 34baacfb9..2c7e52c67 100644
--- a/compiler/docgen.nim
+++ b/compiler/docgen.nim
@@ -344,9 +344,9 @@ proc nodeToHighlightedHtml(d: PDoc; n: PNode; result: var Rope; renderFlags: TRe
       if procTokenPos == tokenPos-2 and procLink != nil:
         dispA(d.conf, result, "<a href=\"#$2\"><span class=\"Identifier\">$1</span></a>",
               "\\spanIdentifier{$1}", [rope(esc(d.target, literal)), procLink])
-      elif s != nil and s.kind == skType and sfExported in s.flags and
-          s.owner != nil and belongsToPackage(d.conf, s.owner) and
-          d.target == outHtml:
+      elif s != nil and s.kind in {skType, skVar, skLet, skConst} and
+           sfExported in s.flags and s.owner != nil and
+           belongsToPackage(d.conf, s.owner) and d.target == outHtml:
         let external = externalDep(d, s.owner)
         result.addf "<a href=\"$1#$2\"><span class=\"Identifier\">$3</span></a>",
           [rope changeFileExt(external, "html"), rope literal,
diff --git a/compiler/parser.nim b/compiler/parser.nim
index 1acfe1b98..95ec5f765 100644
--- a/compiler/parser.nim
+++ b/compiler/parser.nim
@@ -400,7 +400,8 @@ proc exprList(p: var TParser, endTok: TTokType, result: PNode) =
 proc exprColonEqExprListAux(p: var TParser, endTok: TTokType, result: PNode) =
   assert(endTok in {tkCurlyRi, tkCurlyDotRi, tkBracketRi, tkParRi})
   getTok(p)
-  optInd(p, result)
+  flexComment(p, result)
+  optPar(p)
   # progress guaranteed
   while p.tok.tokType != endTok and p.tok.tokType != tkEof:
     var a = exprColonEqExpr(p)
@@ -2085,7 +2086,7 @@ proc parseConstant(p: var TParser): PNode =
       addSon(result, p.emptyNode)
   eat(p, tkEquals)
   optInd(p, result)
-  addSon(result, parseExpr(p))
+  addSon(result, parseStmtListExpr(p))
   indAndComment(p, result)
 
 proc parseBind(p: var TParser, k: TNodeKind): PNode =
diff --git a/compiler/renderer.nim b/compiler/renderer.nim
index 2fef1234a..832add378 100644
--- a/compiler/renderer.nim
+++ b/compiler/renderer.nim
@@ -1217,8 +1217,14 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
     else:
       put(g, tkDistinct, "distinct")
   of nkTypeDef:
-    gsub(g, n, 0)
-    gsub(g, n, 1)
+    if n.sons[0].kind == nkPragmaExpr:
+      # generate pragma after generic
+      gsub(g, n.sons[0], 0)
+      gsub(g, n, 1)
+      gsub(g, n.sons[0], 1)
+    else:
+      gsub(g, n, 0)
+      gsub(g, n, 1)
     put(g, tkSpaces, Space)
     if n.len > 2 and n.sons[2].kind != nkEmpty:
       putWithSpace(g, tkEquals, "=")
diff --git a/compiler/vmdef.nim b/compiler/vmdef.nim
index 6099bfb9f..608f20526 100644
--- a/compiler/vmdef.nim
+++ b/compiler/vmdef.nim
@@ -17,7 +17,7 @@ const
   byteExcess* = 128 # we use excess-K for immediates
   wordExcess* = 32768
 
-  MaxLoopIterations* = 3_000_000 # max iterations of all loops
+  MaxLoopIterations* = 10_000_000 # max iterations of all loops
 
 
 type
diff --git a/lib/impure/nre.nim b/lib/impure/nre.nim
index 823cae1a3..5c5125ba1 100644
--- a/lib/impure/nre.nim
+++ b/lib/impure/nre.nim
@@ -442,7 +442,7 @@ proc extractOptions(pattern: string): tuple[pattern: string, flags: int, study:
 # }}}
 
 proc destroyRegex(pattern: Regex) =
-  pcre.free(pattern.pcreObj)
+  pcre.free_substring(cast[cstring](pattern.pcreObj))
   pattern.pcreObj = nil
   if pattern.pcreExtra != nil:
     pcre.free_study(pattern.pcreExtra)
diff --git a/lib/impure/re.nim b/lib/impure/re.nim
index 6f57185e6..4f32cd5fb 100644
--- a/lib/impure/re.nim
+++ b/lib/impure/re.nim
@@ -60,9 +60,12 @@ proc rawCompile(pattern: string, flags: cint): ptr Pcre =
     raiseInvalidRegex($msg & "\n" & pattern & "\n" & spaces(offset) & "^\n")
 
 proc finalizeRegEx(x: Regex) =
-  pcre.free(x.h)
+  # XXX This is a hack, but PCRE does not export its "free" function properly.
+  # Sigh. The hack relies on PCRE's implementation (see ``pcre_get.c``).
+  # Fortunately the implementation is unlikely to change.
+  pcre.free_substring(cast[cstring](x.h))
   if not isNil(x.e):
-    pcre.free_study(x.e)
+    pcre.free_substring(cast[cstring](x.e))
 
 proc re*(s: string, flags = {reStudy}): Regex =
   ## Constructor of regular expressions.
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index fa32c10c4..b0b17260e 100644
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -35,6 +35,7 @@
 ##   `execShellCmd proc <#execShellCmd,string>`_
 ## * `parseopt module <parseopt.html>`_ for command-line parser beyond
 ##   `parseCmdLine proc <#parseCmdLine,string>`_
+## * `uri module <uri.html>`_
 ## * `distros module <distros.html>`_
 ## * `dynlib module <dynlib.html>`_
 ## * `streams module <streams.html>`_
@@ -115,13 +116,15 @@ proc joinPath*(head, tail: string): string {.
   ##
   ## If `head` is the empty string, `tail` is returned. If `tail` is the empty
   ## string, `head` is returned with a trailing path separator. If `tail` starts
-  ## with a path separator it will be removed when concatenated to `head`. Other
-  ## path separators not located on boundaries won't be modified.
+  ## with a path separator it will be removed when concatenated to `head`.
+  ## Path separators will be normalized.
   ##
   ## See also:
   ## * `joinPath(varargs) proc <#joinPath,varargs[string]>`_
   ## * `/ proc <#/,string,string>`_
   ## * `splitPath proc <#splitPath,string>`_
+  ## * `uri.combine proc <uri.html#combine,Uri,Uri>`_
+  ## * `uri./ proc <uri.html#/,Uri,string>`_
   runnableExamples:
     when defined(posix):
       assert joinPath("usr", "lib") == "usr/lib"
@@ -186,6 +189,8 @@ proc `/`*(head, tail: string): string {.noSideEffect.} =
   ## * `joinPath(head, tail) proc <#joinPath,string,string>`_
   ## * `joinPath(varargs) proc <#joinPath,varargs[string]>`_
   ## * `splitPath proc <#splitPath,string>`_
+  ## * `uri.combine proc <uri.html#combine,Uri,Uri>`_
+  ## * `uri./ proc <uri.html#/,Uri,string>`_
   runnableExamples:
     when defined(posix):
       assert "usr" / "" == "usr/"
diff --git a/lib/system/embedded.nim b/lib/system/embedded.nim
index fb89e7f0f..d1e05dad5 100644
--- a/lib/system/embedded.nim
+++ b/lib/system/embedded.nim
@@ -29,8 +29,7 @@ const
   nativeStackTraceSupported = false
   hasSomeStackTrace = false
 
-proc quitOrDebug() {.inline.} =
-  quit(1)
+proc quitOrDebug() {.noreturn, importc: "abort", header: "<stdlib.h>", nodecl.}
 
 proc raiseException(e: ref Exception, ename: cstring) {.compilerRtl.} =
   sysFatal(ReraiseError, "exception handling is not available")
diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim
index 8849caee5..75a0e8967 100644
--- a/lib/system/excpt.nim
+++ b/lib/system/excpt.nim
@@ -38,10 +38,15 @@ proc showErrorMessage(data: cstring) {.gcsafe.} =
       writeToStdErr(data)
 
 proc quitOrDebug() {.inline.} =
-  when not defined(endb):
-    quit(1)
-  else:
+  when defined(endb):
     endbStep() # call the debugger
+  elif not defined(nodejs) and not defined(nimscript):
+    when nimvm:
+      quit(1)
+    else:
+      c_abort()
+  else:
+    quit(1)
 
 proc chckIndx(i, a, b: int): int {.inline, compilerproc, benign.}
 proc chckRange(i, a, b: int): int {.inline, compilerproc, benign.}
diff --git a/lib/wrappers/pcre.nim b/lib/wrappers/pcre.nim
index b7975abb8..c4bb24cfd 100644
--- a/lib/wrappers/pcre.nim
+++ b/lib/wrappers/pcre.nim
@@ -341,8 +341,6 @@ proc compile2*(pattern: cstring,
                erroffset: ptr cint,
                tableptr: pointer): ptr Pcre
 
-proc free*(p: ptr Pcre)
-
 proc config*(what: cint,
              where: pointer): cint
 
diff --git a/nimdoc/testproject/expected/testproject.html b/nimdoc/testproject/expected/testproject.html
index afe6ffa6b..c562e731e 100644
--- a/nimdoc/testproject/expected/testproject.html
+++ b/nimdoc/testproject/expected/testproject.html
@@ -907,7 +907,7 @@ The enum B.
 <h1><a class="toc-backref" href="#8">Vars</a></h1>
 <dl class="item">
 <a id="aVariable"></a>
-<dt><pre><span class="Identifier">aVariable</span><span class="Other">:</span> <span class="Identifier">array</span><span class="Other">[</span><span class="DecNumber">1</span><span class="Other">,</span> <span class="Identifier">int</span><span class="Other">]</span></pre></dt>
+<dt><pre><a href="testproject.html#aVariable"><span class="Identifier">aVariable</span></a><span class="Other">:</span> <span class="Identifier">array</span><span class="Other">[</span><span class="DecNumber">1</span><span class="Other">,</span> <span class="Identifier">int</span><span class="Other">]</span></pre></dt>
 <dd>
 
 
diff --git a/tests/errmsgs/tcall_with_default_arg.nim b/tests/errmsgs/tcall_with_default_arg.nim
new file mode 100644
index 000000000..1cc86638f
--- /dev/null
+++ b/tests/errmsgs/tcall_with_default_arg.nim
@@ -0,0 +1,18 @@
+discard """
+outputsub: '''tcall_with_default_arg.nim(16) anotherFoo'''
+exitcode: 1
+"""
+# issue: #5604
+
+proc fail() =
+  raise newException(ValueError, "dead")
+
+proc getDefault(): int = 123
+
+proc bar*(arg1: int = getDefault()) =
+  fail()
+
+proc anotherFoo(input: string) =
+  bar()
+
+anotherFoo("123")
diff --git a/tests/parser/tletcolon.nim b/tests/parser/tletcolon.nim
index 7eaa5e3e5..a2dde148a 100644
--- a/tests/parser/tletcolon.nim
+++ b/tests/parser/tletcolon.nim
@@ -58,4 +58,18 @@ block:
     var y = 2
     echo "block expression works"
     y*y
-  doAssert x == 4
\ No newline at end of file
+  doAssert x == 4
+
+
+# bug 10861
+macro foo(a: untyped): untyped = 
+  a             
+
+let c1 = foo:
+  1 + 1
+
+const c2 = foo:
+  1 + 1
+
+const c3 = 
+  foo: 1 + 1