diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim index f991b4ac6c3e0..5cd7b28b0fde4 100644 --- a/compiler/semmagic.nim +++ b/compiler/semmagic.nim @@ -564,5 +564,9 @@ proc magicsAfterOverloadResolution(c: PContext, n: PNode, if not checkIsolate(n[1]): localError(c.config, n.info, "expression cannot be isolated: " & $n[1]) result = n + of mPred: + if n[1].typ.skipTypes(abstractInst).kind in {tyUInt..tyUInt64}: + n[0].sym.magic = mSubU + result = n else: result = n diff --git a/tests/misc/tunsignedconv.nim b/tests/misc/tunsignedconv.nim index 0e5fc43dbb1d4..07fc03e59f6fa 100644 --- a/tests/misc/tunsignedconv.nim +++ b/tests/misc/tunsignedconv.nim @@ -59,3 +59,13 @@ discard $(x1,) # bug #13698 let n: csize = 1 # xxx should that be csize_t or is that essential here? doAssert $n.int32 == "1" + +# bug #14616 + +let limit = 1'u64 + +let rangeVar = 0'u64 ..< limit + +doAssert repr(rangeVar) == """[a = 0, +b = 0] +"""