This commit is contained in:
Andreas Rumpf
2020-03-20 14:35:45 +01:00
committed by GitHub
parent f4dbdd311f
commit 253e1b9e96
2 changed files with 9 additions and 2 deletions

View File

@@ -1985,8 +1985,10 @@ proc genRangeChck(p: BProc, n: PNode, d: var TLoc) =
discard cgsym(p.module, raiser)
# This seems to be bug-compatible with Nim version 1 but what we
# should really do here is to check if uint64Value < high(int)
let n0t = n[0].typ
let boundaryCast =
if n[0].typ.skipTypes(abstractVarRange).kind in {tyUInt, tyUInt32, tyUInt64}:
if n0t.skipTypes(abstractVarRange).kind in {tyUInt, tyUInt32, tyUInt64} or
(n0t.sym != nil and sfSystemModule in n0t.sym.owner.flags and n0t.sym.name.s == "csize"):
"(NI64)"
else:
""

View File

@@ -1,5 +1,6 @@
discard """
output: '''uint'''
output: '''uint
1'''
"""
# Tests unsigned literals and implicit conversion between uints and ints
@@ -60,3 +61,7 @@ discard $x0
const x1 = cast[uint](-1)
discard $(x1,)
# bug 13698
let n: csize = 1
echo n.int32