Replace countup(x, y-1) with x ..< y
This commit is contained in:
parent
9ffab44c35
commit
f18b3af9d4
58 changed files with 312 additions and 312 deletions
|
|
@ -276,7 +276,7 @@ proc semConv(c: PContext, n: PNode): PNode =
|
|||
localError(c.config, n.info, "illegal conversion from '$1' to '$2'" %
|
||||
[op.typ.typeToString, result.typ.typeToString])
|
||||
else:
|
||||
for i in countup(0, sonsLen(op) - 1):
|
||||
for i in 0 ..< sonsLen(op):
|
||||
let it = op.sons[i]
|
||||
let status = checkConvertible(c, result.typ, it.typ)
|
||||
if status in {convOK, convNotNeedeed}:
|
||||
|
|
@ -428,7 +428,7 @@ proc semIs(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
|||
|
||||
proc semOpAux(c: PContext, n: PNode) =
|
||||
const flags = {efDetermineType}
|
||||
for i in countup(1, n.sonsLen-1):
|
||||
for i in 1 ..< n.sonsLen:
|
||||
var a = n.sons[i]
|
||||
if a.kind == nkExprEqExpr and sonsLen(a) == 2:
|
||||
let info = a.sons[0].info
|
||||
|
|
@ -446,13 +446,13 @@ proc overloadedCallOpr(c: PContext, n: PNode): PNode =
|
|||
else:
|
||||
result = newNodeI(nkCall, n.info)
|
||||
addSon(result, newIdentNode(par, n.info))
|
||||
for i in countup(0, sonsLen(n) - 1): addSon(result, n.sons[i])
|
||||
for i in 0 ..< sonsLen(n): addSon(result, n.sons[i])
|
||||
result = semExpr(c, result)
|
||||
|
||||
proc changeType(c: PContext; n: PNode, newType: PType, check: bool) =
|
||||
case n.kind
|
||||
of nkCurly, nkBracket:
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
for i in 0 ..< sonsLen(n):
|
||||
changeType(c, n.sons[i], elemType(newType), check)
|
||||
of nkPar, nkTupleConstr:
|
||||
let tup = newType.skipTypes({tyGenericInst, tyAlias, tySink, tyDistinct})
|
||||
|
|
@ -461,7 +461,7 @@ proc changeType(c: PContext; n: PNode, newType: PType, check: bool) =
|
|||
globalError(c.config, n.info, "no tuple type for constructor")
|
||||
elif sonsLen(n) > 0 and n.sons[0].kind == nkExprColonExpr:
|
||||
# named tuple?
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
for i in 0 ..< sonsLen(n):
|
||||
var m = n.sons[i].sons[0]
|
||||
if m.kind != nkSym:
|
||||
globalError(c.config, m.info, "invalid tuple constructor")
|
||||
|
|
@ -475,7 +475,7 @@ proc changeType(c: PContext; n: PNode, newType: PType, check: bool) =
|
|||
else:
|
||||
changeType(c, n.sons[i].sons[1], tup.sons[i], check)
|
||||
else:
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
for i in 0 ..< sonsLen(n):
|
||||
changeType(c, n.sons[i], tup.sons[i], check)
|
||||
when false:
|
||||
var m = n.sons[i]
|
||||
|
|
@ -523,7 +523,7 @@ proc semArrayConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
|||
var typ = yy.typ
|
||||
addSon(result, yy)
|
||||
#var typ = skipTypes(result.sons[0].typ, {tyGenericInst, tyVar, tyLent, tyOrdinal})
|
||||
for i in countup(1, sonsLen(n) - 1):
|
||||
for i in 1 ..< sonsLen(n):
|
||||
x = n.sons[i]
|
||||
if x.kind == nkExprColonExpr and sonsLen(x) == 2:
|
||||
var idx = semConstExpr(c, x.sons[0])
|
||||
|
|
@ -640,7 +640,7 @@ proc analyseIfAddressTakenInCall(c: PContext, n: PNode) =
|
|||
if n.sons[0].kind == nkSym and n.sons[0].sym.magic in FakeVarParams:
|
||||
# BUGFIX: check for L-Value still needs to be done for the arguments!
|
||||
# note sometimes this is eval'ed twice so we check for nkHiddenAddr here:
|
||||
for i in countup(1, sonsLen(n) - 1):
|
||||
for i in 1 ..< sonsLen(n):
|
||||
if i < sonsLen(t) and t.sons[i] != nil and
|
||||
skipTypes(t.sons[i], abstractInst-{tyTypeDesc}).kind == tyVar:
|
||||
let it = n[i]
|
||||
|
|
@ -656,7 +656,7 @@ proc analyseIfAddressTakenInCall(c: PContext, n: PNode) =
|
|||
localError(c.config, n.info, errXStackEscape % renderTree(n[1], {renderNoComments}))
|
||||
|
||||
return
|
||||
for i in countup(1, sonsLen(n) - 1):
|
||||
for i in 1 ..< sonsLen(n):
|
||||
let n = if n.kind == nkHiddenDeref: n[0] else: n
|
||||
if n.sons[i].kind == nkHiddenCallConv:
|
||||
# we need to recurse explicitly here as converters can create nested
|
||||
|
|
@ -843,7 +843,7 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
|||
result = n0
|
||||
result.kind = nkCall
|
||||
result.flags.incl nfExplicitCall
|
||||
for i in countup(1, sonsLen(n) - 1): addSon(result, n.sons[i])
|
||||
for i in 1 ..< sonsLen(n): addSon(result, n.sons[i])
|
||||
return semExpr(c, result, flags)
|
||||
else:
|
||||
n.sons[0] = n0
|
||||
|
|
@ -874,7 +874,7 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
|||
else:
|
||||
var hasErrorType = false
|
||||
var msg = "type mismatch: got <"
|
||||
for i in countup(1, sonsLen(n) - 1):
|
||||
for i in 1 ..< sonsLen(n):
|
||||
if i > 1: add(msg, ", ")
|
||||
let nt = n.sons[i].typ
|
||||
add(msg, typeToString(nt))
|
||||
|
|
@ -962,7 +962,7 @@ proc lookupInRecordAndBuildCheck(c: PContext, n, r: PNode, field: PIdent,
|
|||
result = nil
|
||||
case r.kind
|
||||
of nkRecList:
|
||||
for i in countup(0, sonsLen(r) - 1):
|
||||
for i in 0 ..< sonsLen(r):
|
||||
result = lookupInRecordAndBuildCheck(c, n, r.sons[i], field, check)
|
||||
if result != nil: return
|
||||
of nkRecCase:
|
||||
|
|
@ -972,7 +972,7 @@ proc lookupInRecordAndBuildCheck(c: PContext, n, r: PNode, field: PIdent,
|
|||
if result != nil: return
|
||||
let setType = createSetType(c, r.sons[0].typ)
|
||||
var s = newNodeIT(nkCurly, r.info, setType)
|
||||
for i in countup(1, sonsLen(r) - 1):
|
||||
for i in 1 ..< sonsLen(r):
|
||||
var it = r.sons[i]
|
||||
case it.kind
|
||||
of nkOfBranch:
|
||||
|
|
@ -1406,7 +1406,7 @@ proc semSubscript(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
|||
tyUncheckedArray:
|
||||
if n.len != 2: return nil
|
||||
n.sons[0] = makeDeref(n.sons[0])
|
||||
for i in countup(1, sonsLen(n) - 1):
|
||||
for i in 1 ..< sonsLen(n):
|
||||
n.sons[i] = semExprWithType(c, n.sons[i],
|
||||
flags*{efInTypeof, efDetermineType})
|
||||
# Arrays index type is dictated by the range's type
|
||||
|
|
@ -1856,7 +1856,7 @@ proc semExpandToAst(c: PContext, n: PNode): PNode =
|
|||
onUse(n.info, expandedSym)
|
||||
|
||||
if isCallExpr(macroCall):
|
||||
for i in countup(1, macroCall.len-1):
|
||||
for i in 1 ..< macroCall.len:
|
||||
#if macroCall.sons[0].typ.sons[i].kind != tyExpr:
|
||||
macroCall.sons[i] = semExprWithType(c, macroCall[i], {})
|
||||
# performing overloading resolution here produces too serious regressions:
|
||||
|
|
@ -2195,7 +2195,7 @@ proc semWhen(c: PContext, n: PNode, semCheck = true): PNode =
|
|||
whenNimvm = exprNode.sym.magic == mNimvm
|
||||
if whenNimvm: n.flags.incl nfLL
|
||||
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
for i in 0 ..< sonsLen(n):
|
||||
var it = n.sons[i]
|
||||
case it.kind
|
||||
of nkElifBranch, nkElifExpr:
|
||||
|
|
@ -2238,7 +2238,7 @@ proc semSetConstr(c: PContext, n: PNode): PNode =
|
|||
else:
|
||||
# only semantic checking for all elements, later type checking:
|
||||
var typ: PType = nil
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
for i in 0 ..< sonsLen(n):
|
||||
if isRange(n.sons[i]):
|
||||
checkSonsLen(n.sons[i], 3, c.config)
|
||||
n.sons[i].sons[1] = semExprWithType(c, n.sons[i].sons[1])
|
||||
|
|
@ -2262,7 +2262,7 @@ proc semSetConstr(c: PContext, n: PNode): PNode =
|
|||
elif lengthOrd(c.config, typ) > MaxSetElements:
|
||||
typ = makeRangeType(c, 0, MaxSetElements-1, n.info)
|
||||
addSonSkipIntLit(result.typ, typ)
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
for i in 0 ..< sonsLen(n):
|
||||
var m: PNode
|
||||
let info = n.sons[i].info
|
||||
if isRange(n.sons[i]):
|
||||
|
|
@ -2282,7 +2282,7 @@ proc semTableConstr(c: PContext, n: PNode): PNode =
|
|||
for i in 0..n.len-1:
|
||||
var x = n.sons[i]
|
||||
if x.kind == nkExprColonExpr and sonsLen(x) == 2:
|
||||
for j in countup(lastKey, i-1):
|
||||
for j in lastKey ..< i:
|
||||
var pair = newNodeI(nkTupleConstr, x.info)
|
||||
pair.add(n.sons[j])
|
||||
pair.add(x[1])
|
||||
|
|
@ -2313,7 +2313,7 @@ proc checkPar(c: PContext; n: PNode): TParKind =
|
|||
else:
|
||||
if n.sons[0].kind == nkExprColonExpr: result = paTupleFields
|
||||
else: result = paTuplePositions
|
||||
for i in countup(0, length - 1):
|
||||
for i in 0 ..< length:
|
||||
if result == paTupleFields:
|
||||
if (n.sons[i].kind != nkExprColonExpr) or
|
||||
not (n.sons[i].sons[0].kind in {nkSym, nkIdent}):
|
||||
|
|
@ -2329,7 +2329,7 @@ proc semTupleFieldsConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
|||
var typ = newTypeS(tyTuple, c)
|
||||
typ.n = newNodeI(nkRecList, n.info) # nkIdentDefs
|
||||
var ids = initIntSet()
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
for i in 0 ..< sonsLen(n):
|
||||
if n[i].kind != nkExprColonExpr or n[i][0].kind notin {nkSym, nkIdent}:
|
||||
illFormedAst(n.sons[i], c.config)
|
||||
var id: PIdent
|
||||
|
|
@ -2352,7 +2352,7 @@ proc semTuplePositionsConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
|||
result = n # we don't modify n, but compute the type:
|
||||
result.kind = nkTupleConstr
|
||||
var typ = newTypeS(tyTuple, c) # leave typ.n nil!
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
for i in 0 ..< sonsLen(n):
|
||||
n.sons[i] = semExprWithType(c, n.sons[i], flags*{efAllowDestructor})
|
||||
addSonSkipIntLit(typ, n.sons[i].typ)
|
||||
result.typ = typ
|
||||
|
|
@ -2360,7 +2360,7 @@ proc semTuplePositionsConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
|||
proc isTupleType(n: PNode): bool =
|
||||
if n.len == 0:
|
||||
return false # don't interpret () as type
|
||||
for i in countup(0, n.len - 1):
|
||||
for i in 0 ..< n.len:
|
||||
if n[i].typ == nil or n[i].typ.kind != tyTypeDesc:
|
||||
return false
|
||||
return true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue