Fix 14127 js from int to int casting (#15918)

* fix #14127 from int to int casting

* add test for #14127

* use template for test, also test uint2int

* move to tests/types/t14127_cast_number.nim targets:c cpp js
This commit is contained in:
Bung 2020-11-12 01:41:49 +08:00 • committed by GitHub
commit a81434a890
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 2 deletions

View file

@ -2406,8 +2406,7 @@ proc genCast(p: PProc, n: PNode, r: var TCompRes) =
r.res = "($1 $2)" % [r.res, trimmer]
elif toInt:
if fromInt:
let trimmer = unsignedTrimmer(dest.size)
r.res = "($1 $2)" % [r.res, trimmer]
return
elif fromUint:
if src.size == 4 and dest.size == 4:
# XXX prevent multi evaluations