summary refs log tree commit diff stats
path: root/compiler/sempass2.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/sempass2.nim')
-rw-r--r--compiler/sempass2.nim19
1 files changed, 10 insertions, 9 deletions
diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim
index e989eb4a6..396ea6606 100644
--- a/compiler/sempass2.nim
+++ b/compiler/sempass2.nim
@@ -822,9 +822,6 @@ proc checkForSink(tracked: PEffects; n: PNode) =
   if tracked.inIfStmt == 0 and optSinkInference in tracked.config.options:
     checkForSink(tracked.config, tracked.c.idgen, tracked.owner, n)
 
-proc strictFuncsActive(tracked: PEffects): bool {.inline.} =
-  sfNoSideEffect in tracked.owner.flags and strictFuncs in tracked.c.features and not tracked.inEnforcedNoSideEffects
-
 proc trackCall(tracked: PEffects; n: PNode) =
   template gcsafeAndSideeffectCheck() =
     if notGcSafe(op) and not importedFromC(a):
@@ -934,9 +931,11 @@ proc trackCall(tracked: PEffects; n: PNode) =
           # initialized until after the call. Since we do this after we analysed the
           # call, this is fine.
           initVar(tracked, n[i].skipAddr, false)
-        if tracked.strictFuncsActive and isDangerousLocation(n[i].skipAddr, tracked.owner):
-          localError(tracked.config, n[i].info,
-            "cannot pass $1 to `var T` parameter within a strict func" % renderTree(n[i]))
+        if strictFuncs in tracked.c.features and not tracked.inEnforcedNoSideEffects and
+           isDangerousLocation(n[i].skipAddr, tracked.owner):
+          if sfNoSideEffect in tracked.owner.flags:
+            localError(tracked.config, n[i].info,
+              "cannot pass $1 to `var T` parameter within a strict func" % renderTree(n[i]))
           tracked.hasSideEffect = true
       else: discard
 
@@ -1090,10 +1089,12 @@ proc track(tracked: PEffects, n: PNode) =
       createTypeBoundOps(tracked, n[0].typ, n.info)
     if n[0].kind != nkSym or not isLocalSym(tracked, n[0].sym):
       checkForSink(tracked, n[1])
-      if tracked.strictFuncsActive and isDangerousLocation(n[0], tracked.owner):
+      if strictFuncs in tracked.c.features and not tracked.inEnforcedNoSideEffects and
+         isDangerousLocation(n[0], tracked.owner):
         tracked.hasSideEffect = true
-        localError(tracked.config, n[0].info,
-            "cannot mutate location $1 within a strict func" % renderTree(n[0]))
+        if sfNoSideEffect in tracked.owner.flags:
+          localError(tracked.config, n[0].info,
+              "cannot mutate location $1 within a strict func" % renderTree(n[0]))
   of nkVarSection, nkLetSection:
     for child in n:
       let last = lastSon(child)