diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2021-09-06 17:43:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-06 17:43:03 +0200 |
commit | 34a53e804943ceaf3900feb6e89194aa03236c0a (patch) | |
tree | e883cb339a6e51c47667881f7c4253ed599cf312 | |
parent | 90bfd342504fd1a6a9e4c8f232bf7c35eab92f82 (diff) | |
download | Nim-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>
-rw-r--r-- | compiler/ccgcalls.nim | 1 | ||||
-rw-r--r-- | compiler/sem.nim | 6 | ||||
-rw-r--r-- | compiler/transf.nim | 5 | ||||
-rw-r--r-- | testament/categories.nim | 6 | ||||
-rw-r--r-- | testament/important_packages.nim | 5 | ||||
-rw-r--r-- | tests/effects/teffects6.nim | 20 |
6 files changed, 36 insertions, 7 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 diff --git a/testament/categories.nim b/testament/categories.nim index 6702d24a2..46cc3b210 100644 --- a/testament/categories.nim +++ b/testament/categories.nim @@ -459,11 +459,13 @@ proc testNimblePackages(r: var TResults; cat: Category; packageFilter: string) = r.addResult(packageFileTest, targetC, "", "", reBuildFailed) except JsonParsingError: - echo "[Warning] - Cannot run nimble tests: Invalid package file." + errors = 1 r.addResult(packageFileTest, targetC, "", "Invalid package file", reBuildFailed) + raise except ValueError: - echo "[Warning] - $#" % getCurrentExceptionMsg() + errors = 1 r.addResult(packageFileTest, targetC, "", "Unknown package", reBuildFailed) + raise # bug #18805 finally: if errors == 0: removeDir(packagesDir) diff --git a/testament/important_packages.nim b/testament/important_packages.nim index a91246562..025121990 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -114,7 +114,6 @@ pkg "nimsvg" pkg "nimterop", "nimble minitest" pkg "nimwc", "nim c nimwc.nim" pkg "nimx", "nim c --threads:on test/main.nim", allowFailure = true -pkg "nimYAML", "nim c -r test/tserialization.nim" pkg "nitter", "nim c src/nitter.nim", "https://github.com/zedeus/nitter" pkg "norm", "nim c -r tests/sqlite/trows.nim" pkg "npeg", "nimble testarc" @@ -162,7 +161,7 @@ pkg "weave", "nimble test_gc_arc", allowFailure = true pkg "websocket", "nim c websocket.nim" pkg "winim", allowFailure = true pkg "with" -pkg "ws" -pkg "yaml", "nim build" +pkg "ws", allowFailure = true +pkg "yaml", "nim c -r test/tserialization.nim" pkg "zero_functional", "nim c -r -d:nimNoLentIterators test.nim" pkg "zippy" diff --git a/tests/effects/teffects6.nim b/tests/effects/teffects6.nim index 6a4eea155..4a39e0dca 100644 --- a/tests/effects/teffects6.nim +++ b/tests/effects/teffects6.nim @@ -34,3 +34,23 @@ proc use*() = use() + +# bug #12642 +import os + +proc raises() {.raises: Exception.} = discard +proc harmless() {.raises: [].} = discard + +let x = if paramStr(1) == "true": harmless else: raises + +let + choice = 0 + +proc withoutSideEffects(): int = 0 +proc withSideEffects(): int = echo "foo" # the echo causes the side effect + +let procPtr = case choice + of 0: withoutSideEffects + else: withSideEffects + +echo procPtr.repr |