From 02a451dc5d88c4811e7465b3de4e9dad61bf3f5c Mon Sep 17 00:00:00 2001 From: flywind Date: Mon, 17 Jan 2022 12:07:17 +0800 Subject: [PATCH 01/24] enable stricteffects --- config/config.nims | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/config.nims b/config/config.nims index 893d6960fa1a3..62928b0867c30 100644 --- a/config/config.nims +++ b/config/config.nims @@ -16,3 +16,6 @@ when defined(nimStrictMode): # future work: XDeclaredButNotUsed switch("define", "nimVersion:" & NimVersion) +when defined(nimHasEffectsOf): + switch("experimental", "strictEffects") + switch("warningAsError", "Effect:on") From 0f9a4467eaa0ab3e515aa715681efadffaf15957 Mon Sep 17 00:00:00 2001 From: flywind Date: Wed, 19 Jan 2022 17:00:16 +0800 Subject: [PATCH 02/24] add gcsafe --- lib/pure/pegs.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pure/pegs.nim b/lib/pure/pegs.nim index bac8b1a0e9d4e..495f861f97089 100644 --- a/lib/pure/pegs.nim +++ b/lib/pure/pegs.nim @@ -559,7 +559,7 @@ template matchOrParse(mopProc: untyped) = # procs. For the former, *enter* and *leave* event handler code generators # are provided which just return *discard*. - proc mopProc(s: string, p: Peg, start: int, c: var Captures): int = + proc mopProc(s: string, p: Peg, start: int, c: var Captures): int {.gcsafe.} = proc matchBackRef(s: string, p: Peg, start: int, c: var Captures): int = # Parse handler code must run in an *of* clause of its own for each # *PegKind*, so we encapsulate the identical clause body for From f8f31ab65e9b1261202144bd7b4e5fc93aad2b5e Mon Sep 17 00:00:00 2001 From: flywind Date: Thu, 20 Jan 2022 09:32:21 +0800 Subject: [PATCH 03/24] fix tests --- tests/effects/teffects6.nim | 2 +- tests/effects/tgcsafe.nim | 4 ++-- tests/effects/tnosideeffect.nim | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/effects/teffects6.nim b/tests/effects/teffects6.nim index 4a39e0dca0b5b..d3af224348ee9 100644 --- a/tests/effects/teffects6.nim +++ b/tests/effects/teffects6.nim @@ -21,7 +21,7 @@ createMenuItem(s, "Go to definition...", ) -proc noRaise(x: proc()) {.raises: [].} = +proc noRaise(x: proc()) {.raises: [], effectsOf: x.} = # unknown call that might raise anything, but valid: x() diff --git a/tests/effects/tgcsafe.nim b/tests/effects/tgcsafe.nim index 363624f19566b..cfac3ddd813d6 100644 --- a/tests/effects/tgcsafe.nim +++ b/tests/effects/tgcsafe.nim @@ -1,5 +1,5 @@ discard """ - errormsg: "'mainUnsafe' is not GC-safe" + errormsg: "'mainUnsafe' is not GC-safe as it performs an indirect call here" line: 26 cmd: "nim $target --hints:on --threads:on $options $file" """ @@ -13,7 +13,7 @@ proc myproc(i: int) {.gcsafe.} = if isNil(global_proc): return -proc mymap(x: proc ()) = +proc mymap(x: proc ()) {.effectsOf: x.} = x() var diff --git a/tests/effects/tnosideeffect.nim b/tests/effects/tnosideeffect.nim index 9cabb35a2c652..9fc2f74d48ba4 100644 --- a/tests/effects/tnosideeffect.nim +++ b/tests/effects/tnosideeffect.nim @@ -1,5 +1,5 @@ block: # `.noSideEffect` - func foo(bar: proc(): int): int = bar() + func foo(bar: proc(): int): int {.effectsOf: bar.} = bar() var count = 0 proc fn1(): int = 1 proc fn2(): int = (count.inc; count) From fdf82e635dac4e0ef5d861f7abf8439bbcccda27 Mon Sep 17 00:00:00 2001 From: flywind Date: Thu, 20 Jan 2022 10:28:37 +0800 Subject: [PATCH 04/24] fix ci --- tests/closure/tnested.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/closure/tnested.nim b/tests/closure/tnested.nim index ca8d0e08b4746..a481023e9f4a4 100644 --- a/tests/closure/tnested.nim +++ b/tests/closure/tnested.nim @@ -33,7 +33,7 @@ py py px 6 -proc (){.closure, gcsafe, locks: 0.} +proc (){.closure, noSideEffect, gcsafe, locks: 0.} ''' """ From b0a9ea62b364b8f54a820b8d4b1a845e8638d63c Mon Sep 17 00:00:00 2001 From: flywind Date: Thu, 20 Jan 2022 15:42:56 +0800 Subject: [PATCH 05/24] use func --- lib/system.nim | 2 +- nimsuggest/sexp.nim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/system.nim b/lib/system.nim index 02da048e49efb..b13d9c04febb8 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -1877,7 +1877,7 @@ proc pop*[T](s: var seq[T]): T {.inline, noSideEffect.} = result = s[L] setLen(s, L) -proc `==`*[T: tuple|object](x, y: T): bool = +func `==`*[T: tuple|object](x, y: T): bool = ## Generic `==` operator for tuples that is lifted from the components. ## of `x` and `y`. for a, b in fields(x, y): diff --git a/nimsuggest/sexp.nim b/nimsuggest/sexp.nim index 31f4988e1274f..4fcdea068e039 100644 --- a/nimsuggest/sexp.nim +++ b/nimsuggest/sexp.nim @@ -409,7 +409,7 @@ macro convertSexp*(x: untyped): untyped = ## `%` for every element. result = toSexp(x) -proc `==`* (a, b: SexpNode): bool {.noSideEffect.} = +func `==`* (a, b: SexpNode): bool = ## Check two nodes for equality if a.isNil: if b.isNil: return true From 9fcbf623cae640cf00a3d096e395d27958856d30 Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Thu, 6 Oct 2022 23:08:45 +0800 Subject: [PATCH 06/24] fixes pegs tests --- tests/stdlib/tpegs.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/stdlib/tpegs.nim b/tests/stdlib/tpegs.nim index cbc8fe205bc35..ab2a6d395a733 100644 --- a/tests/stdlib/tpegs.nim +++ b/tests/stdlib/tpegs.nim @@ -106,9 +106,9 @@ block: block: var - pStack: seq[string] = @[] - valStack: seq[float] = @[] - opStack = "" + pStack {.threadvar.}: seq[string] + valStack {.threadvar.}: seq[float] + opStack {.threadvar.}: string let parseArithExpr = pegAst.eventParser: pkNonTerminal: From 5842184712c8ce9ab4f2b279e83f6f0a33aad116 Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Fri, 7 Oct 2022 14:53:41 +0800 Subject: [PATCH 07/24] explicitly mark repr related procs with noSideEffect --- lib/system/repr_v2.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/system/repr_v2.nim b/lib/system/repr_v2.nim index 0e9bec0f3b99a..46717d87a7a8e 100644 --- a/lib/system/repr_v2.nim +++ b/lib/system/repr_v2.nim @@ -100,7 +100,7 @@ template repr*(x: distinct): string = template repr*(t: typedesc): string = $t -proc reprObject[T: tuple|object](res: var string, x: T) = +proc reprObject[T: tuple|object](res: var string, x: T) {.noSideEffect.} = res.add '(' var firstElement = true const isNamed = T is object or isNamedTuple(T) @@ -121,7 +121,7 @@ proc reprObject[T: tuple|object](res: var string, x: T) = res.add(')') -proc repr*[T: tuple|object](x: T): string = +proc repr*[T: tuple|object](x: T): string {.noSideEffect.} = ## Generic `repr` operator for tuples that is lifted from the components ## of `x`. Example: ## @@ -133,7 +133,7 @@ proc repr*[T: tuple|object](x: T): string = result = $typeof(x) reprObject(result, x) -proc repr*[T](x: ref T | ptr T): string = +proc repr*[T](x: ref T | ptr T): string {.noSideEffect.} = if isNil(x): return "nil" when T is object: result = $typeof(x) @@ -142,7 +142,7 @@ proc repr*[T](x: ref T | ptr T): string = result = when typeof(x) is ref: "ref " else: "ptr " result.add repr(x[]) -proc collectionToRepr[T](x: T, prefix, separator, suffix: string): string = +proc collectionToRepr[T](x: T, prefix, separator, suffix: string): string {.noSideEffect.} = result = prefix var firstElement = true for value in items(x): From 617d48cb7c0a12d996df63cd7f7b1ff34e3a8085 Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Fri, 14 Oct 2022 19:11:51 +0800 Subject: [PATCH 08/24] add nimLegacyEffects --- compiler/nim.cfg | 5 ----- compiler/sempass2.nim | 8 ++++---- config/config.nims | 3 --- doc/manual.md | 4 +--- testament/important_packages.nim | 2 +- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/compiler/nim.cfg b/compiler/nim.cfg index 020104fe5ec81..2df0010852aeb 100644 --- a/compiler/nim.cfg +++ b/compiler/nim.cfg @@ -30,11 +30,6 @@ define:useStdoutAsStdmsg warning[ObservableStores]: off @end -@if nimHasEffectsOf: - experimental:strictEffects - warningAsError:Effect:on -@end - @if nimHasWarningAsError: warningAsError:GcUnsafe2:on @end diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index f2da33e8b1714..09808554a1021 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -495,7 +495,7 @@ proc isIndirectCall(tracked: PEffects; n: PNode): bool = if n.kind != nkSym: result = true elif n.sym.kind == skParam: - if strictEffects in tracked.c.features: + if not isDefined(tracked.c.config, "nimLegacyEffects"): if tracked.owner == n.sym.owner and sfEffectsDelayed in n.sym.flags: result = false # it is not a harmful call else: @@ -581,7 +581,7 @@ proc isOwnedProcVar(tracked: PEffects; n: PNode): bool = tracked.owner == n.sym.owner #if result and sfPolymorphic notin n.sym.flags: # echo tracked.config $ n.info, " different here!" - if strictEffects in tracked.c.features: + if not isDefined(tracked.c.config, "nimLegacyEffects"): result = result and sfEffectsDelayed in n.sym.flags proc isNoEffectList(n: PNode): bool {.inline.} = @@ -598,7 +598,7 @@ proc trackOperandForIndirectCall(tracked: PEffects, n: PNode, formals: PType; ar # assume indirect calls are taken here: if op != nil and op.kind == tyProc and n.skipConv.kind != nkNilLit and not isTrival(caller) and - ((param != nil and sfEffectsDelayed in param.flags) or strictEffects notin tracked.c.features): + ((param != nil and sfEffectsDelayed in param.flags) or isDefined(tracked.c.config, "nimLegacyEffects")): internalAssert tracked.config, op.n[0].kind == nkEffectList var effectList = op.n[0] @@ -844,7 +844,7 @@ proc trackCall(tracked: PEffects; n: PNode) = assumeTheWorst(tracked, n, op) gcsafeAndSideeffectCheck() else: - if strictEffects in tracked.c.features and a.kind == nkSym and + if not isDefined(tracked.c.config, "nimLegacyEffects") and a.kind == nkSym and a.sym.kind in routineKinds: propagateEffects(tracked, n, a.sym) else: diff --git a/config/config.nims b/config/config.nims index 294b4cb800fef..8dcfc4e7e9aed 100644 --- a/config/config.nims +++ b/config/config.nims @@ -27,6 +27,3 @@ when defined(windows) and not defined(booting): switch("define", "nimVersion:" & NimVersion) -when defined(nimHasEffectsOf): - switch("experimental", "strictEffects") - switch("warningAsError", "Effect:on") diff --git a/doc/manual.md b/doc/manual.md index df486d446d650..8431eba3d8bd1 100644 --- a/doc/manual.md +++ b/doc/manual.md @@ -4952,8 +4952,7 @@ Effect system ============= **Note**: The rules for effect tracking changed with the release of version -1.6 of the Nim compiler. This section describes the new rules that are activated -via `--experimental:strictEffects`. +1.6 of the Nim compiler. Exception tracking @@ -5073,7 +5072,6 @@ conservative in its effect analysis: ```nim test = "nim c $1" status = 1 {.push warningAsError[Effect]: on.} - {.experimental: "strictEffects".} import algorithm diff --git a/testament/important_packages.nim b/testament/important_packages.nim index 3652d179cfe86..0ed77b73a83b6 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -67,7 +67,7 @@ pkg "fidget" pkg "fragments", "nim c -r fragments/dsl.nim", allowFailure = true # pending https://github.com/nim-lang/packages/issues/2115 pkg "fusion" pkg "gara" -pkg "glob" +pkg "glob", "nimble install -y regex@#HEAD;nimble test" pkg "ggplotnim", "nim c -d:noCairo -r tests/tests.nim" pkg "gittyup", "nimble test", "https://github.com/disruptek/gittyup", allowFailure = true pkg "gnuplot", "nim c gnuplot.nim" From 29f1d71598dceded01d32cbee645e286eb5365c6 Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Fri, 14 Oct 2022 20:46:59 +0800 Subject: [PATCH 09/24] change URL --- testament/important_packages.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testament/important_packages.nim b/testament/important_packages.nim index 0ed77b73a83b6..adb738dc25a6c 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -67,7 +67,7 @@ pkg "fidget" pkg "fragments", "nim c -r fragments/dsl.nim", allowFailure = true # pending https://github.com/nim-lang/packages/issues/2115 pkg "fusion" pkg "gara" -pkg "glob", "nimble install -y regex@#HEAD;nimble test" +pkg "glob" pkg "ggplotnim", "nim c -d:noCairo -r tests/tests.nim" pkg "gittyup", "nimble test", "https://github.com/disruptek/gittyup", allowFailure = true pkg "gnuplot", "nim c gnuplot.nim" @@ -109,7 +109,7 @@ pkg "nimongo", "nimble test_ci", allowFailure = true pkg "nimph", "nimble test", "https://github.com/disruptek/nimph", allowFailure = true pkg "nimPNG", useHead = true pkg "nimpy", "nim c -r tests/nimfrompy.nim" -pkg "nimquery" +pkg "nimquery", url = "https://github.com/nim-lang/nimquery" pkg "nimsl" pkg "nimsvg" pkg "nimterop", "nimble minitest" @@ -146,7 +146,7 @@ pkg "strslice" pkg "strunicode", "nim c -r --mm:refc src/strunicode.nim" pkg "supersnappy" pkg "synthesis" -pkg "telebot", "nim c -o:tbot -r src/telebot.nim" +pkg "telebot", "nim c -o:tbot -r src/telebot.nim", url = "https://github.com/nim-lang/telebot.nim" pkg "tempdir" pkg "templates" pkg "tensordsl", "nim c -r --mm:refc tests/tests.nim", "https://krux02@bitbucket.org/krux02/tensordslnim.git" From 9194f7c73c5f55984436171edc0a27ec0f7c6207 Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Fri, 14 Oct 2022 20:59:13 +0800 Subject: [PATCH 10/24] fixes docopt --- testament/important_packages.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testament/important_packages.nim b/testament/important_packages.nim index adb738dc25a6c..052caeb3eeaaf 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -60,7 +60,7 @@ pkg "criterion", allowFailure = true # pending https://github.com/disruptek/crit pkg "datamancer" pkg "dashing", "nim c tests/functional.nim" pkg "delaunay", url = "https://github.com/nim-lang/DelaunayNim", useHead = true -pkg "docopt" +pkg "docopt", url = "https://github.com/nim-lang/docopt.nim", useHead = true pkg "easygl", "nim c -o:egl -r src/easygl.nim", "https://github.com/jackmott/easygl" pkg "elvis" pkg "fidget" From 86470a7afb4c2598962f59f119dc6a7f26a53aa7 Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Fri, 14 Oct 2022 21:54:41 +0800 Subject: [PATCH 11/24] add `raises: []` to repr --- lib/system/repr_v2.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/system/repr_v2.nim b/lib/system/repr_v2.nim index 46717d87a7a8e..5fe65fe791d32 100644 --- a/lib/system/repr_v2.nim +++ b/lib/system/repr_v2.nim @@ -133,7 +133,7 @@ proc repr*[T: tuple|object](x: T): string {.noSideEffect.} = result = $typeof(x) reprObject(result, x) -proc repr*[T](x: ref T | ptr T): string {.noSideEffect.} = +proc repr*[T](x: ref T | ptr T): string {.noSideEffect, raises: [].} = if isNil(x): return "nil" when T is object: result = $typeof(x) From 4a1c8a644b23fa8cde8237ad8ac1715cadaabd17 Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Fri, 14 Oct 2022 22:05:44 +0800 Subject: [PATCH 12/24] fixes weave --- testament/important_packages.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testament/important_packages.nim b/testament/important_packages.nim index 052caeb3eeaaf..823abb436e557 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -158,7 +158,7 @@ pkg "tiny_sqlite" pkg "unicodedb", "nim c -d:release -r tests/tests.nim" pkg "unicodeplus", "nim c -d:release -r tests/tests.nim" pkg "unpack" -pkg "weave", "nimble install -y cligen synthesis;nimble test_gc_arc" +pkg "weave", "nimble install -y cligen synthesis;nimble test_gc_arc", url = "https://github.com/mratsim/weave/pull/184" pkg "websocket", "nim c websocket.nim" pkg "winim", "nim c winim.nim" pkg "with" From 1b7d473c6b30dc76eaf647b67c8a09e2d1408a70 Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Fri, 14 Oct 2022 22:30:23 +0800 Subject: [PATCH 13/24] fixes nimyaml --- testament/important_packages.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testament/important_packages.nim b/testament/important_packages.nim index 823abb436e557..6e6373e588f26 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -163,6 +163,6 @@ pkg "websocket", "nim c websocket.nim" pkg "winim", "nim c winim.nim" pkg "with" pkg "ws", allowFailure = true -pkg "yaml", "nim c -r test/tserialization.nim" +pkg "yaml", "nim c -r test/tserialization.nim", url = "https://github.com/flyx/NimYAML/pull/125", useHead = true pkg "zero_functional", "nim c -r -d:nimNoLentIterators test.nim" pkg "zippy" From 94fa914a3fd6e7dd3325ccfb3fd33f899f2e2eeb Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Fri, 14 Oct 2022 22:31:33 +0800 Subject: [PATCH 14/24] mistake --- testament/important_packages.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testament/important_packages.nim b/testament/important_packages.nim index 6e6373e588f26..9f2d22249ee03 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -158,7 +158,7 @@ pkg "tiny_sqlite" pkg "unicodedb", "nim c -d:release -r tests/tests.nim" pkg "unicodeplus", "nim c -d:release -r tests/tests.nim" pkg "unpack" -pkg "weave", "nimble install -y cligen synthesis;nimble test_gc_arc", url = "https://github.com/mratsim/weave/pull/184" +pkg "weave", "nimble install -y cligen synthesis;nimble test_gc_arc", url = "https://github.com/nim-lang/weave" pkg "websocket", "nim c websocket.nim" pkg "winim", "nim c winim.nim" pkg "with" From e5b06b98d1ed1ea77e3cf926bcfaf26df8f9d64f Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Fri, 14 Oct 2022 22:35:30 +0800 Subject: [PATCH 15/24] fixes glob --- testament/important_packages.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testament/important_packages.nim b/testament/important_packages.nim index 9f2d22249ee03..940f123912a3b 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -67,7 +67,7 @@ pkg "fidget" pkg "fragments", "nim c -r fragments/dsl.nim", allowFailure = true # pending https://github.com/nim-lang/packages/issues/2115 pkg "fusion" pkg "gara" -pkg "glob" +pkg "glob", url = "https://github.com/nim-lang/glob", useHead = true pkg "ggplotnim", "nim c -d:noCairo -r tests/tests.nim" pkg "gittyup", "nimble test", "https://github.com/disruptek/gittyup", allowFailure = true pkg "gnuplot", "nim c gnuplot.nim" From b8583913708a5f487396e1a8ec6d6bdc87094a29 Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Fri, 14 Oct 2022 22:37:49 +0800 Subject: [PATCH 16/24] fixes parsetoml --- testament/important_packages.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testament/important_packages.nim b/testament/important_packages.nim index 940f123912a3b..4fddba93a16c0 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -121,7 +121,7 @@ pkg "npeg", "nimble testarc" pkg "numericalnim", "nimble nimCI" pkg "optionsutils" pkg "ormin", "nim c -o:orminn ormin.nim" -pkg "parsetoml" +pkg "parsetoml", url = "https://github.com/nim-lang/parsetoml", useHead = true pkg "patty" pkg "pixie" pkg "plotly", "nim c examples/all.nim" From afda060a77ee437815b0f6f3596ab974aec0b50c Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Fri, 14 Oct 2022 23:15:45 +0800 Subject: [PATCH 17/24] Update testament/important_packages.nim --- testament/important_packages.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testament/important_packages.nim b/testament/important_packages.nim index 4fddba93a16c0..301c14072c29d 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -163,6 +163,6 @@ pkg "websocket", "nim c websocket.nim" pkg "winim", "nim c winim.nim" pkg "with" pkg "ws", allowFailure = true -pkg "yaml", "nim c -r test/tserialization.nim", url = "https://github.com/flyx/NimYAML/pull/125", useHead = true +pkg "yaml", "nim c -r test/tserialization.nim", url = "https://github.com/nim-lang/NimYAML", useHead = true pkg "zero_functional", "nim c -r -d:nimNoLentIterators test.nim" pkg "zippy" From 2ebcfff337d4bb315c49b83171693b30ec336fec Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Fri, 14 Oct 2022 23:16:44 +0800 Subject: [PATCH 18/24] Apply suggestions from code review --- testament/important_packages.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testament/important_packages.nim b/testament/important_packages.nim index 301c14072c29d..0bc8fefe28da5 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -109,7 +109,7 @@ pkg "nimongo", "nimble test_ci", allowFailure = true pkg "nimph", "nimble test", "https://github.com/disruptek/nimph", allowFailure = true pkg "nimPNG", useHead = true pkg "nimpy", "nim c -r tests/nimfrompy.nim" -pkg "nimquery", url = "https://github.com/nim-lang/nimquery" +pkg "nimquery", url = "https://github.com/nim-lang/nimquery", useHead = true pkg "nimsl" pkg "nimsvg" pkg "nimterop", "nimble minitest" @@ -146,7 +146,7 @@ pkg "strslice" pkg "strunicode", "nim c -r --mm:refc src/strunicode.nim" pkg "supersnappy" pkg "synthesis" -pkg "telebot", "nim c -o:tbot -r src/telebot.nim", url = "https://github.com/nim-lang/telebot.nim" +pkg "telebot", "nim c -o:tbot -r src/telebot.nim", url = "https://github.com/nim-lang/telebot.nim, useHead = true" pkg "tempdir" pkg "templates" pkg "tensordsl", "nim c -r --mm:refc tests/tests.nim", "https://krux02@bitbucket.org/krux02/tensordslnim.git" @@ -158,7 +158,7 @@ pkg "tiny_sqlite" pkg "unicodedb", "nim c -d:release -r tests/tests.nim" pkg "unicodeplus", "nim c -d:release -r tests/tests.nim" pkg "unpack" -pkg "weave", "nimble install -y cligen synthesis;nimble test_gc_arc", url = "https://github.com/nim-lang/weave" +pkg "weave", "nimble install -y cligen synthesis;nimble test_gc_arc", url = "https://github.com/nim-lang/weave", useHead = true pkg "websocket", "nim c websocket.nim" pkg "winim", "nim c winim.nim" pkg "with" From 57253c9c8ee7ff94982730ea174e09f648ced179 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Fri, 14 Oct 2022 23:43:02 +0800 Subject: [PATCH 19/24] Update testament/important_packages.nim --- testament/important_packages.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testament/important_packages.nim b/testament/important_packages.nim index 0bc8fefe28da5..a9b2353eddbd9 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -146,7 +146,7 @@ pkg "strslice" pkg "strunicode", "nim c -r --mm:refc src/strunicode.nim" pkg "supersnappy" pkg "synthesis" -pkg "telebot", "nim c -o:tbot -r src/telebot.nim", url = "https://github.com/nim-lang/telebot.nim, useHead = true" +pkg "telebot", "nim c -o:tbot -r src/telebot.nim", url = "https://github.com/nim-lang/telebot.nim", useHead = true pkg "tempdir" pkg "templates" pkg "tensordsl", "nim c -r --mm:refc tests/tests.nim", "https://krux02@bitbucket.org/krux02/tensordslnim.git" From daf21b4255a11e87bf627bfcb11359e8dc206b88 Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Sat, 15 Oct 2022 11:27:25 +0800 Subject: [PATCH 20/24] fixes more --- lib/system/repr_v2.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/system/repr_v2.nim b/lib/system/repr_v2.nim index 5fe65fe791d32..1e982da207ca3 100644 --- a/lib/system/repr_v2.nim +++ b/lib/system/repr_v2.nim @@ -100,7 +100,7 @@ template repr*(x: distinct): string = template repr*(t: typedesc): string = $t -proc reprObject[T: tuple|object](res: var string, x: T) {.noSideEffect.} = +proc reprObject[T: tuple|object](res: var string, x: T) {.noSideEffect, raises: [].} = res.add '(' var firstElement = true const isNamed = T is object or isNamedTuple(T) From bd1b7a994d2769ccee61eab86b5faa08b81623f7 Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Sat, 15 Oct 2022 12:49:18 +0800 Subject: [PATCH 21/24] more no raises --- lib/system/repr_v2.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/system/repr_v2.nim b/lib/system/repr_v2.nim index 1e982da207ca3..a2047c7ca2c0b 100644 --- a/lib/system/repr_v2.nim +++ b/lib/system/repr_v2.nim @@ -142,7 +142,7 @@ proc repr*[T](x: ref T | ptr T): string {.noSideEffect, raises: [].} = result = when typeof(x) is ref: "ref " else: "ptr " result.add repr(x[]) -proc collectionToRepr[T](x: T, prefix, separator, suffix: string): string {.noSideEffect.} = +proc collectionToRepr[T](x: T, prefix, separator, suffix: string): string {.noSideEffect, raises: [].} = result = prefix var firstElement = true for value in items(x): From ca5cda0a1e094b3c1b77d63191e1d61d0a068221 Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Sat, 15 Oct 2022 12:52:39 +0800 Subject: [PATCH 22/24] change URL --- testament/important_packages.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testament/important_packages.nim b/testament/important_packages.nim index a9b2353eddbd9..55a943f595123 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -68,7 +68,7 @@ pkg "fragments", "nim c -r fragments/dsl.nim", allowFailure = true # pending htt pkg "fusion" pkg "gara" pkg "glob", url = "https://github.com/nim-lang/glob", useHead = true -pkg "ggplotnim", "nim c -d:noCairo -r tests/tests.nim" +pkg "ggplotnim", "nim c -d:noCairo -r tests/tests.nim", url = "https://github.com/nim-lang/ggplotnim", useHead = true pkg "gittyup", "nimble test", "https://github.com/disruptek/gittyup", allowFailure = true pkg "gnuplot", "nim c gnuplot.nim" # pkg "gram", "nim c -r --gc:arc --define:danger tests/test.nim", "https://github.com/disruptek/gram" From 204f51a11c0125e4982618b31c4d3913378dd102 Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Sat, 15 Oct 2022 13:24:48 +0800 Subject: [PATCH 23/24] try repr --- lib/system/repr_v2.nim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/system/repr_v2.nim b/lib/system/repr_v2.nim index a2047c7ca2c0b..60c09e07306c5 100644 --- a/lib/system/repr_v2.nim +++ b/lib/system/repr_v2.nim @@ -31,7 +31,7 @@ proc repr*(x: bool): string {.magic: "BoolToStr", noSideEffect.} ## repr for a boolean argument. Returns `x` ## converted to the string "false" or "true". -proc repr*(x: char): string {.noSideEffect.} = +proc repr*(x: char): string {.noSideEffect, raises: [].} = ## repr for a character argument. Returns `x` ## converted to an escaped string. ## @@ -47,7 +47,7 @@ proc repr*(x: char): string {.noSideEffect.} = result.add x result.add '\'' -proc repr*(x: string | cstring): string {.noSideEffect.} = +proc repr*(x: string | cstring): string {.noSideEffect, raises: [].} = ## repr for a string argument. Returns `x` ## converted to a quoted and escaped string. result.add '\"' @@ -63,7 +63,7 @@ proc repr*(x: string | cstring): string {.noSideEffect.} = result.add x[i] result.add '\"' -proc repr*[Enum: enum](x: Enum): string {.magic: "EnumToStr", noSideEffect.} +proc repr*[Enum: enum](x: Enum): string {.magic: "EnumToStr", noSideEffect, raises: [].} ## repr for an enumeration argument. This works for ## any enumeration type thanks to compiler magic. ## @@ -121,7 +121,7 @@ proc reprObject[T: tuple|object](res: var string, x: T) {.noSideEffect, raises: res.add(')') -proc repr*[T: tuple|object](x: T): string {.noSideEffect.} = +proc repr*[T: tuple|object](x: T): string {.noSideEffect, raises: [].} = ## Generic `repr` operator for tuples that is lifted from the components ## of `x`. Example: ## @@ -189,4 +189,4 @@ proc repr*[T](x: openArray[T]): string = ## ## .. code-block:: Nim ## $(@[23, 45].toOpenArray(0, 1)) == "[23, 45]" - collectionToRepr(x, "[", ", ", "]") + collectionToRepr(x, "[", ", ", "]") \ No newline at end of file From 0f771a2abbba3fddbbecaeddb9abc5ace9f6378d Mon Sep 17 00:00:00 2001 From: xflywind <43030857+ringabout@users.noreply.github.com> Date: Sat, 15 Oct 2022 18:15:36 +0800 Subject: [PATCH 24/24] add legacy:laxEffects --- changelog.md | 3 +++ compiler/options.nim | 2 ++ compiler/sempass2.nim | 8 ++++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index ddb299be94419..fdbc721447a56 100644 --- a/changelog.md +++ b/changelog.md @@ -89,6 +89,9 @@ - ORC is now the default memory management strategy. Use `--mm:refc` for a transition period. +- `strictEffects` are no longer experimental. + Use `legacy:laxEffects` to keep backward compatibility. + - The `gorge`/`staticExec` calls will now return a descriptive message in the output if the execution fails for whatever reason. To get back legacy behaviour use `-d:nimLegacyGorgeErrors`. diff --git a/compiler/options.nim b/compiler/options.nim index 6257f89693ed9..9043362d90dc0 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -228,6 +228,8 @@ type ## Historically and especially in version 1.0.0 of the language ## conversions to unsigned numbers were checked. In 1.0.4 they ## are not anymore. + laxEffects + ## Lax effects system prior to Nim 2.0. SymbolFilesOption* = enum disabledSf, writeOnlySf, readOnlySf, v2Sf, stressTest diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 09808554a1021..34490f49258df 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -495,7 +495,7 @@ proc isIndirectCall(tracked: PEffects; n: PNode): bool = if n.kind != nkSym: result = true elif n.sym.kind == skParam: - if not isDefined(tracked.c.config, "nimLegacyEffects"): + if laxEffects notin tracked.c.config.legacyFeatures: if tracked.owner == n.sym.owner and sfEffectsDelayed in n.sym.flags: result = false # it is not a harmful call else: @@ -581,7 +581,7 @@ proc isOwnedProcVar(tracked: PEffects; n: PNode): bool = tracked.owner == n.sym.owner #if result and sfPolymorphic notin n.sym.flags: # echo tracked.config $ n.info, " different here!" - if not isDefined(tracked.c.config, "nimLegacyEffects"): + if laxEffects notin tracked.c.config.legacyFeatures: result = result and sfEffectsDelayed in n.sym.flags proc isNoEffectList(n: PNode): bool {.inline.} = @@ -598,7 +598,7 @@ proc trackOperandForIndirectCall(tracked: PEffects, n: PNode, formals: PType; ar # assume indirect calls are taken here: if op != nil and op.kind == tyProc and n.skipConv.kind != nkNilLit and not isTrival(caller) and - ((param != nil and sfEffectsDelayed in param.flags) or isDefined(tracked.c.config, "nimLegacyEffects")): + ((param != nil and sfEffectsDelayed in param.flags) or laxEffects in tracked.c.config.legacyFeatures): internalAssert tracked.config, op.n[0].kind == nkEffectList var effectList = op.n[0] @@ -844,7 +844,7 @@ proc trackCall(tracked: PEffects; n: PNode) = assumeTheWorst(tracked, n, op) gcsafeAndSideeffectCheck() else: - if not isDefined(tracked.c.config, "nimLegacyEffects") and a.kind == nkSym and + if laxEffects notin tracked.c.config.legacyFeatures and a.kind == nkSym and a.sym.kind in routineKinds: propagateEffects(tracked, n, a.sym) else: