fixes #13671 [backport] (#13678)

(cherry picked from commit 5f6997794e)
This commit is contained in:
Andreas Rumpf
2020-03-18 10:37:36 +01:00
committed by narimiran
parent 6f79408576
commit 2dcf32f5c8
2 changed files with 6 additions and 1 deletions

View File

@@ -508,7 +508,7 @@ proc changeType(c: PContext; n: PNode, newType: PType, check: bool) =
addSon(a, m)
changeType(m, tup.sons[i], check)
of nkCharLit..nkUInt64Lit:
if check and n.kind != nkUInt64Lit:
if check and n.kind != nkUInt64Lit and not sameType(n.typ, newType):
let value = n.intVal
if value < firstOrd(c.config, newType) or value > lastOrd(c.config, newType):
localError(c.config, n.info, "cannot convert " & $value &

View File

@@ -55,3 +55,8 @@ const x0 = fun()
echo typeof(x0)
discard $x0
# bug #13671
const x1 = cast[uint](-1)
discard $(x1,)