diff options
author | Araq <rumpf_a@web.de> | 2014-04-03 07:54:58 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-04-03 07:54:58 +0200 |
commit | 62a10df76560d2361955e1072b4b0e1b2a62e477 (patch) | |
tree | 9a581742bcc14ce16feaa2d79bbe82276742c9e9 /compiler | |
parent | e4e87f1cb2fe01a4462f7b0e3d347389f173beff (diff) | |
download | Nim-62a10df76560d2361955e1072b4b0e1b2a62e477.tar.gz |
fixes yet another option type
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/semfold.nim | 18 | ||||
-rw-r--r-- | compiler/types.nim | 4 |
2 files changed, 14 insertions, 8 deletions
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) diff --git a/compiler/types.nim b/compiler/types.nim index ae31d24de..c80f6ff35 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -385,8 +385,8 @@ proc mutateType(t: PType, iter: TTypeMutator, closure: PObject): PType = proc valueToString(a: PNode): string = case a.kind - of nkCharLit..nkUInt64Lit: result = $(a.intVal) - of nkFloatLit..nkFloat128Lit: result = $(a.floatVal) + of nkCharLit..nkUInt64Lit: result = $a.intVal + of nkFloatLit..nkFloat128Lit: result = $a.floatVal of nkStrLit..nkTripleStrLit: result = a.strVal else: result = "<invalid value>" |