Skip to content

Commit

Permalink
fixes #13671 [backport] (#13678)
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq authored Mar 18, 2020
1 parent 51bd442 commit 5f69977
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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 &
Expand Down
5 changes: 5 additions & 0 deletions tests/misc/tunsignedconv.nim
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ const x0 = fun()
echo typeof(x0)

discard $x0

# bug #13671

const x1 = cast[uint](-1)
discard $(x1,)

0 comments on commit 5f69977

Please sign in to comment.