diff options
Diffstat (limited to 'compiler/semfold.nim')
-rw-r--r-- | compiler/semfold.nim | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/semfold.nim b/compiler/semfold.nim index 3bc6f0f23..81efc2436 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -205,8 +205,9 @@ proc evalOp(m: TMagic, n, a, b, c: PNode; g: ModuleGraph): PNode = of mSubI: result = foldSub(getInt(a), getInt(b), n, g) of mMulI: result = foldMul(getInt(a), getInt(b), n, g) of mMinI: - if getInt(a) > getInt(b): result = newIntNodeT(getInt64(b), n, g) - else: result = newIntNodeT(getInt64(a), n, g) + let argA = getInt(a) + let argB = getInt(b) + result = newIntNodeT(if argA < argB: argA else: argB, n, g) of mMaxI: let argA = getInt(a) let argB = getInt(b) @@ -388,13 +389,13 @@ proc leValueConv*(a, b: PNode): bool = case a.kind of nkCharLit..nkUInt64Lit: case b.kind - of nkCharLit..nkUInt64Lit: result = a.intVal <= b.intVal + of nkCharLit..nkUInt64Lit: result = a.getInt <= b.getInt of nkFloatLit..nkFloat128Lit: result = a.intVal <= round(b.floatVal).int else: result = false #internalError(a.info, "leValueConv") of nkFloatLit..nkFloat128Lit: case b.kind of nkFloatLit..nkFloat128Lit: result = a.floatVal <= b.floatVal - of nkCharLit..nkUInt64Lit: result = a.floatVal <= toFloat(int(b.intVal)) + of nkCharLit..nkUInt64Lit: result = a.floatVal <= toFloat64(b.getInt) else: result = false # internalError(a.info, "leValueConv") else: result = false # internalError(a.info, "leValueConv") |