diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim index f9db67d4bb..adef5f364a 100644 --- a/compiler/condsyms.nim +++ b/compiler/condsyms.nim @@ -172,4 +172,3 @@ proc initDefines*(symbols: StringTableRef) = defineSymbol("nimHasDefaultFloatRoundtrip") defineSymbol("nimHasXorSet") - defineSymbol("nimHasLegacyNoStrictDefs") diff --git a/compiler/nim.cfg b/compiler/nim.cfg index c0e4491503..21faf37836 100644 --- a/compiler/nim.cfg +++ b/compiler/nim.cfg @@ -49,7 +49,7 @@ define:useStdoutAsStdmsg @if nimUseStrictDefs: - experimental:strictDefs # deadcode + experimental:strictDefs warningAsError[Uninit]:on warningAsError[ProveInit]:on @end diff --git a/compiler/options.nim b/compiler/options.nim index b456651c82..ea75a68487 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -248,8 +248,6 @@ type ## Useful for libraries that rely on local passC jsNoLambdaLifting ## Old transformation for closures in JS backend - noStrictDefs - ## disable "strictdefs" SymbolFilesOption* = enum disabledSf, writeOnlySf, readOnlySf, v2Sf, stressTest diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index e2b2076530..f959783225 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -878,7 +878,7 @@ proc newHiddenAddrTaken(c: PContext, n: PNode, isOutParam: bool): PNode = if aa notin {arLValue, arLocalLValue}: if aa == arDiscriminant and c.inUncheckedAssignSection > 0: discard "allow access within a cast(unsafeAssign) section" - elif noStrictDefs notin c.config.legacyFeatures and aa == arAddressableConst and + elif strictDefs in c.features and aa == arAddressableConst and sym != nil and sym.kind == skLet and isOutParam: discard "allow let varaibles to be passed to out parameters" else: @@ -2068,8 +2068,7 @@ proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode = let root = getRoot(a) let useStrictDefLet = root != nil and root.kind == skLet and assignable == arAddressableConst and - noStrictDefs notin c.config.legacyFeatures and - isLocalSym(root) + strictDefs in c.features and isLocalSym(root) if le == nil: localError(c.config, a.info, "expression has no type") elif (skipTypes(le, {tyGenericInst, tyAlias, tySink}).kind notin {tyVar} and diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 4ff50efde0..b3fb3d91b2 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -221,7 +221,7 @@ proc initVar(a: PEffects, n: PNode; volatileCheck: bool) = if volatileCheck: makeVolatile(a, s) for x in a.init: if x == s.id: - if noStrictDefs notin a.c.config.legacyFeatures and s.kind == skLet: + if strictDefs in a.c.features and s.kind == skLet: localError(a.config, n.info, errXCannotBeAssignedTo % renderTree(n, {renderNoComments} )) @@ -379,7 +379,7 @@ proc useVar(a: PEffects, n: PNode) = if s.typ.requiresInit: message(a.config, n.info, warnProveInit, s.name.s) elif a.leftPartOfAsgn <= 0: - if noStrictDefs notin a.c.config.legacyFeatures: + if strictDefs in a.c.features: if s.kind == skLet: localError(a.config, n.info, errLetNeedsInit) else: @@ -1664,7 +1664,7 @@ proc trackProc*(c: PContext; s: PSym, body: PNode) = if not isEmptyType(s.typ.returnType) and (s.typ.returnType.requiresInit or s.typ.returnType.skipTypes(abstractInst).kind == tyVar or - noStrictDefs notin c.config.legacyFeatures) and + strictDefs in c.features) and s.kind in {skProc, skFunc, skConverter, skMethod} and s.magic == mNone and sfNoInit notin s.flags: var res = s.ast[resultPos].sym # get result symbol diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 083fb3cf16..75b327afb4 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -975,7 +975,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode = else: checkNilable(c, v) # allow let to not be initialised if imported from C: - if v.kind == skLet and sfImportc notin v.flags and (noStrictDefs in c.config.legacyFeatures or not isLocalSym(v)): + if v.kind == skLet and sfImportc notin v.flags and (strictDefs notin c.features or not isLocalSym(v)): localError(c.config, a.info, errLetNeedsInit) if sfCompileTime in v.flags: var x = newNodeI(result.kind, v.info) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 01eed9df4d..950ebe5196 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -2251,7 +2251,7 @@ proc isLValue(c: PContext; n: PNode, isOutParam = false): bool {.inline.} = result = c.inUncheckedAssignSection > 0 of arAddressableConst: let sym = getRoot(n) - result = noStrictDefs notin c.config.legacyFeatures and sym != nil and sym.kind == skLet and isOutParam + result = strictDefs in c.features and sym != nil and sym.kind == skLet and isOutParam else: result = false diff --git a/config/config.nims b/config/config.nims index 45c6ec58cd..b8979e8e31 100644 --- a/config/config.nims +++ b/config/config.nims @@ -21,4 +21,3 @@ when defined(nimStrictMode): # future work: XDeclaredButNotUsed switch("define", "nimVersion:" & NimVersion) # deadcode -switch("experimental", "strictDefs") diff --git a/tests/msgs/twarningaserror.nim b/tests/msgs/twarningaserror.nim index 22b0e9332a..6f7b760956 100644 --- a/tests/msgs/twarningaserror.nim +++ b/tests/msgs/twarningaserror.nim @@ -1,5 +1,4 @@ discard """ - matrix: "--legacy:nostrictdefs" joinable: false """