summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2022-10-15 20:07:40 +0800
committerGitHub <noreply@github.com>2022-10-15 14:07:40 +0200
commit1e15f975b83951006d69e6e39836aa2d525028c4 (patch)
treed43b2b539494a46df310d91d565c9858e6dcb0b9 /compiler
parent0510a2be0d6df674aa91ae3f2884d98473cade4c (diff)
downloadNim-1e15f975b83951006d69e6e39836aa2d525028c4.tar.gz
fixes #19162; enable `strictEffects` for v2 (#19380)
* enable stricteffects
* add gcsafe
* fix tests
* use func
* fixes pegs tests
* explicitly mark repr related procs with noSideEffect
* add nimLegacyEffects
* change URL
* fixes docopt
* add `raises: []` to repr
* fixes weave
* fixes nimyaml
* fixes glob
* fixes parsetoml
* Apply suggestions from code review
* Update testament/important_packages.nim
* add legacy:laxEffects
Diffstat (limited to 'compiler')
-rw-r--r--compiler/nim.cfg5
-rw-r--r--compiler/options.nim2
-rw-r--r--compiler/sempass2.nim8
3 files changed, 6 insertions, 9 deletions
diff --git a/compiler/nim.cfg b/compiler/nim.cfg
index 020104fe5..2df001085 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/options.nim b/compiler/options.nim
index 6257f8969..9043362d9 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 f2da33e8b..34490f492 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 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 strictEffects in tracked.c.features:
+  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 strictEffects notin tracked.c.features):
+      ((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 strictEffects in tracked.c.features 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: