diff options
author | Araq <rumpf_a@web.de> | 2020-03-16 09:52:07 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2020-03-16 14:55:58 +0100 |
commit | 7205c3ebe2e4e0d57be265214c6a4ac8fa8c1d78 (patch) | |
tree | dac1dd75d9951d008ae2275eb9d60d7dea8e902f | |
parent | 613ea6e85e8289fee92c396e07f8f1b2a991167f (diff) | |
download | Nim-7205c3ebe2e4e0d57be265214c6a4ac8fa8c1d78.tar.gz |
minor code style changes
-rw-r--r-- | compiler/semtypes.nim | 2 | ||||
-rw-r--r-- | compiler/semtypinst.nim | 2 | ||||
-rw-r--r-- | compiler/types.nim | 21 |
3 files changed, 13 insertions, 12 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index e0be620c3..3951c071f 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -225,7 +225,7 @@ proc semRangeAux(c: PContext, n: PNode, prev: PType): PType = if not hasUnknownTypes: if not sameType(rangeT[0].skipTypes({tyRange}), rangeT[1].skipTypes({tyRange})): 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: localError(c.config, n.info, "ordinal or float type expected") elif enumHasHoles(rangeT[0]): diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim index 6d9e9873e..d3ab9d866 100644 --- a/compiler/semtypinst.nim +++ b/compiler/semtypinst.nim @@ -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}: localError(conf, info, "type 'var var' is not allowed") 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: if t.kind == tyObject and t[0] != nil: if t[0].kind != tyObject or tfFinal in t[0].flags: diff --git a/compiler/types.nim b/compiler/types.nim index 3c481ec23..63c5b66f2 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -1612,16 +1612,17 @@ proc isTupleRecursive(t: PType, cycleDetector: var IntSet): bool = if cycleDetector.containsOrIncl(t.id): return true case t.kind: - of tyTuple: - var cycleDetectorCopy: IntSet - for i in 0..<t.len: - assign(cycleDetectorCopy, cycleDetector) - if isTupleRecursive(t[i], cycleDetectorCopy): - return true - of tyAlias, tyRef, tyPtr, tyGenericInst, tyVar, tyLent, tySink, tyArray, tyUncheckedArray, tySequence: - return isTupleRecursive(t.lastSon, cycleDetector) - else: - return false + of tyTuple: + var cycleDetectorCopy: IntSet + for i in 0..<t.len: + assign(cycleDetectorCopy, cycleDetector) + if isTupleRecursive(t[i], cycleDetectorCopy): + return true + of tyAlias, tyRef, tyPtr, tyGenericInst, tyVar, tyLent, tySink, + tyArray, tyUncheckedArray, tySequence: + return isTupleRecursive(t.lastSon, cycleDetector) + else: + return false proc isTupleRecursive*(t: PType): bool = var cycleDetector = initIntSet() |