diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-03-18 10:37:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-18 10:37:36 +0100 |
commit | 5f6997794e1482187decbd074ea274fe32a223d8 (patch) | |
tree | e7a86c0fc6791b6e8be282101f295e7e792b2ca0 | |
parent | 51bd442b88de561ea4729c0ba550e63cad5be969 (diff) | |
download | Nim-5f6997794e1482187decbd074ea274fe32a223d8.tar.gz |
fixes #13671 [backport] (#13678)
-rw-r--r-- | compiler/semexprs.nim | 2 | ||||
-rw-r--r-- | tests/misc/tunsignedconv.nim | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index a479327be..cc8854577 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -522,7 +522,7 @@ proc changeType(c: PContext; n: PNode, newType: PType, check: bool) = a.add m changeType(m, tup[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 & diff --git a/tests/misc/tunsignedconv.nim b/tests/misc/tunsignedconv.nim index af334dd19..085d13aca 100644 --- a/tests/misc/tunsignedconv.nim +++ b/tests/misc/tunsignedconv.nim @@ -55,3 +55,8 @@ const x0 = fun() echo typeof(x0) discard $x0 + +# bug #13671 + +const x1 = cast[uint](-1) +discard $(x1,) |