From 62a10df76560d2361955e1072b4b0e1b2a62e477 Mon Sep 17 00:00:00 2001 From: Araq Date: Thu, 3 Apr 2014 07:54:58 +0200 Subject: fixes yet another option type --- compiler/semfold.nim | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'compiler/semfold.nim') diff --git a/compiler/semfold.nim b/compiler/semfold.nim index 925a80832..caaab2291 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -113,12 +113,18 @@ proc pickMaxInt(n: PNode): BiggestInt = internalError(n.info, "pickMaxInt") proc makeRange(typ: PType, first, last: BiggestInt): PType = - var n = newNode(nkRange) - addSon(n, newIntNode(nkIntLit, min(first, last))) - addSon(n, newIntNode(nkIntLit, max(first, last))) - result = newType(tyRange, typ.owner) - result.n = n - addSonSkipIntLit(result, skipTypes(typ, {tyRange})) + let minA = min(first, last) + let maxA = max(first, last) + let lowerNode = newIntNode(nkIntLit, minA) + if typ.kind == tyInt and minA == maxA: + result = getIntLitType(lowerNode) + else: + var n = newNode(nkRange) + addSon(n, lowerNode) + addSon(n, newIntNode(nkIntLit, maxA)) + result = newType(tyRange, typ.owner) + result.n = n + addSonSkipIntLit(result, skipTypes(typ, {tyRange})) proc makeRangeF(typ: PType, first, last: BiggestFloat): PType = var n = newNode(nkRange) -- cgit 1.4.1-2-gfad0