--nilseqs is now a deprecated noop (#17211)
* --nilseqs is now a deprecated noop * fix tests; fix: future => sugar
This commit is contained in:
parent
bb0c19f42c
commit
6c5872c169
15 changed files with 37 additions and 53 deletions
|
|
@ -85,10 +85,9 @@ proc genLiteral(p: BProc, n: PNode, ty: PType): Rope =
|
|||
of tyNil:
|
||||
result = genNilStringLiteral(p.module, n.info)
|
||||
of tyString:
|
||||
# with the new semantics for 'nil' strings, we can map "" to nil and
|
||||
# with the new semantics for not 'nil' strings, we can map "" to nil and
|
||||
# save tons of allocations:
|
||||
if n.strVal.len == 0 and optNilSeqs notin p.options and
|
||||
optSeqDestructors notin p.config.globalOptions:
|
||||
if n.strVal.len == 0 and optSeqDestructors notin p.config.globalOptions:
|
||||
result = genNilStringLiteral(p.module, n.info)
|
||||
else:
|
||||
result = genStringLiteral(p.module, n)
|
||||
|
|
@ -176,8 +175,7 @@ proc canMove(p: BProc, n: PNode; dest: TLoc): bool =
|
|||
if not isDeepConstExpr(n) or n.len == 0:
|
||||
if skipTypes(n.typ, abstractVarRange).kind == tySequence:
|
||||
return true
|
||||
elif optNilSeqs notin p.options and
|
||||
n.kind in nkStrKinds and n.strVal.len == 0:
|
||||
elif n.kind in nkStrKinds and n.strVal.len == 0:
|
||||
# Empty strings are codegen'd as NIM_NIL so it's just a pointer copy
|
||||
return true
|
||||
result = n.kind in nkCallKinds
|
||||
|
|
@ -1371,8 +1369,7 @@ proc genNewSeq(p: BProc, e: PNode) =
|
|||
getTypeDesc(p.module, seqtype.lastSon),
|
||||
getSeqPayloadType(p.module, seqtype)])
|
||||
else:
|
||||
let lenIsZero = optNilSeqs notin p.options and
|
||||
e[2].kind == nkIntLit and e[2].intVal == 0
|
||||
let lenIsZero = e[2].kind == nkIntLit and e[2].intVal == 0
|
||||
genNewSeqAux(p, a, b.rdLoc, lenIsZero)
|
||||
gcUsage(p.config, e)
|
||||
|
||||
|
|
@ -1497,8 +1494,7 @@ proc genSeqConstr(p: BProc, n: PNode, d: var TLoc) =
|
|||
getSeqPayloadType(p.module, seqtype)])
|
||||
else:
|
||||
# generate call to newSeq before adding the elements per hand:
|
||||
genNewSeqAux(p, dest[], l,
|
||||
optNilSeqs notin p.options and n.len == 0)
|
||||
genNewSeqAux(p, dest[], l, n.len == 0)
|
||||
for i in 0..<n.len:
|
||||
initLoc(arr, locExpr, n[i], OnHeap)
|
||||
arr.r = ropecg(p.module, "$1$3[$2]", [rdLoc(dest[]), intLiteral(i), dataField(p)])
|
||||
|
|
@ -1527,7 +1523,7 @@ proc genArrToSeq(p: BProc, n: PNode, d: var TLoc) =
|
|||
[rdLoc d, L, getTypeDesc(p.module, seqtype.lastSon),
|
||||
getSeqPayloadType(p.module, seqtype)])
|
||||
else:
|
||||
genNewSeqAux(p, d, intLiteral(L), optNilSeqs notin p.options and L == 0)
|
||||
genNewSeqAux(p, d, intLiteral(L), L == 0)
|
||||
initLocExpr(p, n[1], a)
|
||||
# bug #5007; do not produce excessive C source code:
|
||||
if L < 10:
|
||||
|
|
|
|||
|
|
@ -318,7 +318,9 @@ proc testCompileOption*(conf: ConfigRef; switch: string, info: TLineInfo): bool
|
|||
of "implicitstatic": result = contains(conf.options, optImplicitStatic)
|
||||
of "patterns", "trmacros": result = contains(conf.options, optTrMacros)
|
||||
of "excessivestacktrace": result = contains(conf.globalOptions, optExcessiveStackTrace)
|
||||
of "nilseqs": result = contains(conf.options, optNilSeqs)
|
||||
of "nilseqs":
|
||||
warningDeprecated(conf, info, "nilseqs is a deprecated noop")
|
||||
result = false
|
||||
else: invalidCmdLineOption(conf, passCmd1, switch, info)
|
||||
|
||||
proc processPath(conf: ConfigRef; path: string, info: TLineInfo,
|
||||
|
|
@ -650,7 +652,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
|||
else:
|
||||
undefSymbol(conf.symbols, "hotcodereloading")
|
||||
undefSymbol(conf.symbols, "useNimRtl")
|
||||
of "nilseqs": processOnOffSwitch(conf, {optNilSeqs}, arg, pass, info)
|
||||
of "nilseqs": warningDeprecated(conf, info, "nilseqs is a deprecated noop")
|
||||
of "checks", "x": processOnOffSwitch(conf, ChecksOptions, arg, pass, info)
|
||||
of "floatchecks":
|
||||
processOnOffSwitch(conf, {optNaNCheck, optInfCheck}, arg, pass, info)
|
||||
|
|
|
|||
|
|
@ -590,6 +590,9 @@ template localError*(conf: ConfigRef; info: TLineInfo, format: string, params: o
|
|||
template message*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg = "") =
|
||||
liMessage(conf, info, msg, arg, doNothing, instLoc())
|
||||
|
||||
proc warningDeprecated*(conf: ConfigRef, info: TLineInfo = gCmdLineInfo, msg = "") {.inline.} =
|
||||
message(conf, info, warnDeprecated, msg)
|
||||
|
||||
proc internalErrorImpl(conf: ConfigRef; info: TLineInfo, errMsg: string, info2: InstantiationInfo) =
|
||||
if conf.cmd == cmdIdeTools and conf.structuredErrorHook.isNil: return
|
||||
writeContext(conf, info)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ type # please make sure we have under 32 options
|
|||
# evaluation
|
||||
optTrMacros, # en/disable pattern matching
|
||||
optMemTracker,
|
||||
optNilSeqs,
|
||||
optSinkInference # 'sink T' inference
|
||||
optCursorInference
|
||||
|
||||
|
|
|
|||
|
|
@ -556,12 +556,6 @@ proc recordRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
|||
proc allowsNil(f: PType): TTypeRelation {.inline.} =
|
||||
result = if tfNotNil notin f.flags: isSubtype else: isNone
|
||||
|
||||
proc allowsNilDeprecated(c: TCandidate, f: PType): TTypeRelation =
|
||||
if optNilSeqs in c.c.config.options:
|
||||
result = allowsNil(f)
|
||||
else:
|
||||
result = isNone
|
||||
|
||||
proc inconsistentVarTypes(f, a: PType): bool {.inline.} =
|
||||
result = f.kind != a.kind and
|
||||
(f.kind in {tyVar, tyLent, tySink} or a.kind in {tyVar, tyLent, tySink})
|
||||
|
|
@ -1300,7 +1294,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
|
|||
result = isNone
|
||||
elif tfNotNil in f.flags and tfNotNil notin a.flags:
|
||||
result = isNilConversion
|
||||
of tyNil: result = allowsNilDeprecated(c, f)
|
||||
of tyNil: result = isNone
|
||||
else: discard
|
||||
of tyOrdinal:
|
||||
if isOrdinalType(a, allowEnumWithHoles = optNimV1Emulation in c.c.config.globalOptions):
|
||||
|
|
@ -1396,7 +1390,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
|
|||
result = isNilConversion
|
||||
else:
|
||||
result = isEqual
|
||||
of tyNil: result = allowsNilDeprecated(c, f)
|
||||
of tyNil: result = isNone
|
||||
else: discard
|
||||
of tyCString:
|
||||
# conversion from string to cstring is automatic:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue