Skip to content

Commit 2af9ddc

Browse files
authored
revert strictDefs as the default (#24620)
revert #24225 see also https://forum.nim-lang.org/t/12646
1 parent 70d057f commit 2af9ddc

File tree

9 files changed

+8
-14
lines changed

9 files changed

+8
-14
lines changed

compiler/condsyms.nim

-1
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,3 @@ proc initDefines*(symbols: StringTableRef) =
172172
defineSymbol("nimHasDefaultFloatRoundtrip")
173173
defineSymbol("nimHasXorSet")
174174

175-
defineSymbol("nimHasLegacyNoStrictDefs")

compiler/nim.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ define:useStdoutAsStdmsg
4949

5050

5151
@if nimUseStrictDefs:
52-
experimental:strictDefs # deadcode
52+
experimental:strictDefs
5353
warningAsError[Uninit]:on
5454
warningAsError[ProveInit]:on
5555
@end

compiler/options.nim

-2
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,6 @@ type
248248
## Useful for libraries that rely on local passC
249249
jsNoLambdaLifting
250250
## Old transformation for closures in JS backend
251-
noStrictDefs
252-
## disable "strictdefs"
253251

254252
SymbolFilesOption* = enum
255253
disabledSf, writeOnlySf, readOnlySf, v2Sf, stressTest

compiler/semexprs.nim

+2-3
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ proc newHiddenAddrTaken(c: PContext, n: PNode, isOutParam: bool): PNode =
878878
if aa notin {arLValue, arLocalLValue}:
879879
if aa == arDiscriminant and c.inUncheckedAssignSection > 0:
880880
discard "allow access within a cast(unsafeAssign) section"
881-
elif noStrictDefs notin c.config.legacyFeatures and aa == arAddressableConst and
881+
elif strictDefs in c.features and aa == arAddressableConst and
882882
sym != nil and sym.kind == skLet and isOutParam:
883883
discard "allow let varaibles to be passed to out parameters"
884884
else:
@@ -2068,8 +2068,7 @@ proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode =
20682068
let root = getRoot(a)
20692069
let useStrictDefLet = root != nil and root.kind == skLet and
20702070
assignable == arAddressableConst and
2071-
noStrictDefs notin c.config.legacyFeatures and
2072-
isLocalSym(root)
2071+
strictDefs in c.features and isLocalSym(root)
20732072
if le == nil:
20742073
localError(c.config, a.info, "expression has no type")
20752074
elif (skipTypes(le, {tyGenericInst, tyAlias, tySink}).kind notin {tyVar} and

compiler/sempass2.nim

+3-3
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ proc initVar(a: PEffects, n: PNode; volatileCheck: bool) =
221221
if volatileCheck: makeVolatile(a, s)
222222
for x in a.init:
223223
if x == s.id:
224-
if noStrictDefs notin a.c.config.legacyFeatures and s.kind == skLet:
224+
if strictDefs in a.c.features and s.kind == skLet:
225225
localError(a.config, n.info, errXCannotBeAssignedTo %
226226
renderTree(n, {renderNoComments}
227227
))
@@ -379,7 +379,7 @@ proc useVar(a: PEffects, n: PNode) =
379379
if s.typ.requiresInit:
380380
message(a.config, n.info, warnProveInit, s.name.s)
381381
elif a.leftPartOfAsgn <= 0:
382-
if noStrictDefs notin a.c.config.legacyFeatures:
382+
if strictDefs in a.c.features:
383383
if s.kind == skLet:
384384
localError(a.config, n.info, errLetNeedsInit)
385385
else:
@@ -1664,7 +1664,7 @@ proc trackProc*(c: PContext; s: PSym, body: PNode) =
16641664

16651665
if not isEmptyType(s.typ.returnType) and
16661666
(s.typ.returnType.requiresInit or s.typ.returnType.skipTypes(abstractInst).kind == tyVar or
1667-
noStrictDefs notin c.config.legacyFeatures) and
1667+
strictDefs in c.features) and
16681668
s.kind in {skProc, skFunc, skConverter, skMethod} and s.magic == mNone and
16691669
sfNoInit notin s.flags:
16701670
var res = s.ast[resultPos].sym # get result symbol

compiler/semstmts.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
975975
else:
976976
checkNilable(c, v)
977977
# allow let to not be initialised if imported from C:
978-
if v.kind == skLet and sfImportc notin v.flags and (noStrictDefs in c.config.legacyFeatures or not isLocalSym(v)):
978+
if v.kind == skLet and sfImportc notin v.flags and (strictDefs notin c.features or not isLocalSym(v)):
979979
localError(c.config, a.info, errLetNeedsInit)
980980
if sfCompileTime in v.flags:
981981
var x = newNodeI(result.kind, v.info)

compiler/sigmatch.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -2251,7 +2251,7 @@ proc isLValue(c: PContext; n: PNode, isOutParam = false): bool {.inline.} =
22512251
result = c.inUncheckedAssignSection > 0
22522252
of arAddressableConst:
22532253
let sym = getRoot(n)
2254-
result = noStrictDefs notin c.config.legacyFeatures and sym != nil and sym.kind == skLet and isOutParam
2254+
result = strictDefs in c.features and sym != nil and sym.kind == skLet and isOutParam
22552255
else:
22562256
result = false
22572257

config/config.nims

-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ when defined(nimStrictMode):
2121
# future work: XDeclaredButNotUsed
2222

2323
switch("define", "nimVersion:" & NimVersion) # deadcode
24-
switch("experimental", "strictDefs")

tests/msgs/twarningaserror.nim

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
discard """
2-
matrix: "--legacy:nostrictdefs"
32
joinable: false
43
"""
54

0 commit comments

Comments
 (0)