minor code style changes

This commit is contained in:
Araq 2020-03-16 09:52:07 +01:00 • committed by Andreas Rumpf
commit 7205c3ebe2
3 changed files with 13 additions and 12 deletions

View file

@ -225,7 +225,7 @@ proc semRangeAux(c: PContext, n: PNode, prev: PType): PType =
if not hasUnknownTypes: if not hasUnknownTypes:
if not sameType(rangeT[0].skipTypes({tyRange}), rangeT[1].skipTypes({tyRange})): if not sameType(rangeT[0].skipTypes({tyRange}), rangeT[1].skipTypes({tyRange})):
localError(c.config, n.info, "type mismatch") localError(c.config, n.info, "type mismatch")
elif not isOrdinalType(rangeT[0]) and rangeT[0].kind notin tyFloat..tyFloat128 or elif not isOrdinalType(rangeT[0]) and rangeT[0].kind notin {tyFloat..tyFloat128} or
rangeT[0].kind == tyBool: rangeT[0].kind == tyBool:
localError(c.config, n.info, "ordinal or float type expected") localError(c.config, n.info, "ordinal or float type expected")
elif enumHasHoles(rangeT[0]): elif enumHasHoles(rangeT[0]):

View file

@ -25,7 +25,7 @@ proc checkConstructedType*(conf: ConfigRef; info: TLineInfo, typ: PType) =
elif t.kind in {tyVar, tyLent} and t[0].kind in {tyVar, tyLent}: elif t.kind in {tyVar, tyLent} and t[0].kind in {tyVar, tyLent}:
localError(conf, info, "type 'var var' is not allowed") localError(conf, info, "type 'var var' is not allowed")
elif computeSize(conf, t) == szIllegalRecursion or isTupleRecursive(t): elif computeSize(conf, t) == szIllegalRecursion or isTupleRecursive(t):
localError(conf, info, "illegal recursion in type '" & typeToString(t) & "'") localError(conf, info, "illegal recursion in type '" & typeToString(t) & "'")
when false: when false:
if t.kind == tyObject and t[0] != nil: if t.kind == tyObject and t[0] != nil:
if t[0].kind != tyObject or tfFinal in t[0].flags: if t[0].kind != tyObject or tfFinal in t[0].flags:

View file

@ -1612,16 +1612,17 @@ proc isTupleRecursive(t: PType, cycleDetector: var IntSet): bool =
if cycleDetector.containsOrIncl(t.id): if cycleDetector.containsOrIncl(t.id):
return true return true
case t.kind: case t.kind:
of tyTuple: of tyTuple:
var cycleDetectorCopy: IntSet var cycleDetectorCopy: IntSet
for i in 0..<t.len: for i in 0..<t.len:
assign(cycleDetectorCopy, cycleDetector) assign(cycleDetectorCopy, cycleDetector)
if isTupleRecursive(t[i], cycleDetectorCopy): if isTupleRecursive(t[i], cycleDetectorCopy):
return true return true
of tyAlias, tyRef, tyPtr, tyGenericInst, tyVar, tyLent, tySink, tyArray, tyUncheckedArray, tySequence: of tyAlias, tyRef, tyPtr, tyGenericInst, tyVar, tyLent, tySink,
return isTupleRecursive(t.lastSon, cycleDetector) tyArray, tyUncheckedArray, tySequence:
else: return isTupleRecursive(t.lastSon, cycleDetector)
return false else:
return false
proc isTupleRecursive*(t: PType): bool = proc isTupleRecursive*(t: PType): bool =
var cycleDetector = initIntSet() var cycleDetector = initIntSet()