From 6a621b35e7c935655d3cafe840eb69d662e333b7 Mon Sep 17 00:00:00 2001 From: Miran Date: Fri, 11 Sep 2020 01:04:07 +0200 Subject: [PATCH] fix warnings for deprecated `low` and `high` (#15291) --- compiler/ast.nim | 4 ++-- compiler/saturate.nim | 20 ++++++++++---------- compiler/vmgen.nim | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/compiler/ast.nim b/compiler/ast.nim index b1a3a4a7b5..8baf49265b 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -1356,8 +1356,8 @@ proc newType*(kind: TTypeKind, owner: PSym): PType = writeStackTrace() proc mergeLoc(a: var TLoc, b: TLoc) = - if a.k == low(a.k): a.k = b.k - if a.storage == low(a.storage): a.storage = b.storage + if a.k == low(typeof(a.k)): a.k = b.k + if a.storage == low(typeof(a.storage)): a.storage = b.storage a.flags.incl b.flags if a.lode == nil: a.lode = b.lode if a.r == nil: a.r = b.r diff --git a/compiler/saturate.nim b/compiler/saturate.nim index 9e8919514a..fe6e03c8b0 100644 --- a/compiler/saturate.nim +++ b/compiler/saturate.nim @@ -15,33 +15,33 @@ proc `|+|`*(a, b: BiggestInt): BiggestInt = if (result xor a) >= 0'i64 or (result xor b) >= 0'i64: return result if a < 0 or b < 0: - result = low(result) + result = low(typeof(result)) else: - result = high(result) + result = high(typeof(result)) proc `|-|`*(a, b: BiggestInt): BiggestInt = result = a -% b if (result xor a) >= 0'i64 or (result xor not b) >= 0'i64: return result if b > 0: - result = low(result) + result = low(typeof(result)) else: - result = high(result) + result = high(typeof(result)) proc `|abs|`*(a: BiggestInt): BiggestInt = - if a != low(a): + if a != low(typeof(a)): if a >= 0: result = a else: result = -a else: - result = low(a) + result = low(typeof(a)) proc `|div|`*(a, b: BiggestInt): BiggestInt = # (0..5) div (0..4) == (0..5) div (1..4) == (0 div 4)..(5 div 1) if b == 0'i64: # make the same as ``div 1``: result = a - elif a == low(a) and b == -1'i64: - result = high(result) + elif a == low(typeof(a)) and b == -1'i64: + result = high(typeof(result)) else: result = a div b @@ -74,6 +74,6 @@ proc `|*|`*(a, b: BiggestInt): BiggestInt = return result if floatProd >= 0.0: - result = high(result) + result = high(typeof(result)) else: - result = low(result) + result = low(typeof(result)) diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index c2a2f6d424..ad5023aeb3 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -611,7 +611,7 @@ proc genField(c: PCtx; n: PNode): TRegister = if n.kind != nkSym or n.sym.kind != skField: globalError(c.config, n.info, "no field symbol") let s = n.sym - if s.position > high(result): + if s.position > high(typeof(result)): globalError(c.config, n.info, "too large offset! cannot generate code for: " & s.name.s) result = s.position