summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-09-06 17:43:03 +0200
committerGitHub <noreply@github.com>2021-09-06 17:43:03 +0200
commit34a53e804943ceaf3900feb6e89194aa03236c0a (patch)
treee883cb339a6e51c47667881f7c4253ed599cf312 /compiler
parent90bfd342504fd1a6a9e4c8f232bf7c35eab92f82 (diff)
downloadNim-34a53e804943ceaf3900feb6e89194aa03236c0a.tar.gz
fixes #12642 (#18811)
* fixes #12642

* update important packages; refs #18804

* fixes #18805; refs #18806

* fixes a regression

* Update testament/categories.nim

Co-authored-by: flywind <xzsflywind@gmail.com>

* progress

* progress

Co-authored-by: flywind <xzsflywind@gmail.com>
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgcalls.nim1
-rw-r--r--compiler/sem.nim6
-rw-r--r--compiler/transf.nim5
3 files changed, 10 insertions, 2 deletions
diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim
index 828e666a8..f6cc6da74 100644
--- a/compiler/ccgcalls.nim
+++ b/compiler/ccgcalls.nim
@@ -369,6 +369,7 @@ proc genParams(p: BProc, ri: PNode, typ: PType): Rope =
     if ri[i].skipTrivialIndirections.kind == nkSym:
       needTmp[i - 1] = potentialAlias(ri[i], potentialWrites)
     else:
+      #if not ri[i].typ.isCompileTimeOnly:
       var potentialReads: seq[PNode]
       getPotentialReads(ri[i], potentialReads)
       for n in potentialReads:
diff --git a/compiler/sem.nim b/compiler/sem.nim
index 24709cf21..ad0ba1f7c 100644
--- a/compiler/sem.nim
+++ b/compiler/sem.nim
@@ -174,6 +174,12 @@ proc commonType*(c: PContext; x, y: PType): PType =
         result = b #.skipIntLit
       elif a.kind in IntegralTypes and a.n != nil:
         result = a #.skipIntLit
+  elif a.kind == tyProc and b.kind == tyProc:
+    if a.callConv == ccClosure and b.callConv != ccClosure:
+      result = x
+    elif compatibleEffects(a, b) != efCompat or
+        (b.flags * {tfNoSideEffect, tfGcSafe}) < (a.flags * {tfNoSideEffect, tfGcSafe}):
+      result = y
   else:
     var k = tyNone
     if a.kind in {tyRef, tyPtr}:
diff --git a/compiler/transf.nim b/compiler/transf.nim
index 5846e6e3b..89fa89701 100644
--- a/compiler/transf.nim
+++ b/compiler/transf.nim
@@ -1023,8 +1023,9 @@ proc transform(c: PTransf, n: PNode): PNode =
     result[0] = transform(c, n[0])
     # Skip the second son since it only contains an unsemanticized copy of the
     # variable type used by docgen
-    result[1] = n[1]
-    result[2] = transform(c, n[2])
+    let last = n.len-1
+    for i in 1..<last: result[i] = n[i]
+    result[last] = transform(c, n[last])
     # XXX comment handling really sucks:
     if importantComments(c.graph.config):
       result.comment = n.comment