From 1e15f975b83951006d69e6e39836aa2d525028c4 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Sat, 15 Oct 2022 20:07:40 +0800 Subject: 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 --- compiler/nim.cfg | 5 ----- compiler/options.nim | 2 ++ compiler/sempass2.nim | 8 ++++---- 3 files changed, 6 insertions(+), 9 deletions(-) (limited to 'compiler') 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: -- cgit 1.4.1-2-gfad0