parent
b9b53b6ca1
commit
5ba5b5202a
3 changed files with 17 additions and 2 deletions
|
|
@ -439,7 +439,6 @@ proc foldConv(n, a: PNode; g: ModuleGraph; check = false): PNode =
|
||||||
result = newIntNodeT(toInt128(getFloat(a)), n, g)
|
result = newIntNodeT(toInt128(getFloat(a)), n, g)
|
||||||
of tyChar, tyUInt..tyUInt64, tyInt..tyInt64:
|
of tyChar, tyUInt..tyUInt64, tyInt..tyInt64:
|
||||||
var val = a.getOrdValue
|
var val = a.getOrdValue
|
||||||
|
|
||||||
if check: rangeCheck(n, val, g)
|
if check: rangeCheck(n, val, g)
|
||||||
result = newIntNodeT(val, n, g)
|
result = newIntNodeT(val, n, g)
|
||||||
if dstTyp.kind in {tyUInt..tyUInt64}:
|
if dstTyp.kind in {tyUInt..tyUInt64}:
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,11 @@ proc isUnsigned*(t: PType): bool =
|
||||||
t.skipTypes(abstractInst).kind in {tyChar, tyUInt..tyUInt64}
|
t.skipTypes(abstractInst).kind in {tyChar, tyUInt..tyUInt64}
|
||||||
|
|
||||||
proc getOrdValue*(n: PNode; onError = high(Int128)): Int128 =
|
proc getOrdValue*(n: PNode; onError = high(Int128)): Int128 =
|
||||||
case n.kind
|
var k = n.kind
|
||||||
|
if n.typ != nil and n.typ.skipTypes(abstractInst).kind in {tyChar, tyUInt..tyUInt64}:
|
||||||
|
k = nkUIntLit
|
||||||
|
|
||||||
|
case k
|
||||||
of nkCharLit, nkUIntLit..nkUInt64Lit:
|
of nkCharLit, nkUIntLit..nkUInt64Lit:
|
||||||
# XXX: enable this assert
|
# XXX: enable this assert
|
||||||
#assert n.typ == nil or isUnsigned(n.typ), $n.typ
|
#assert n.typ == nil or isUnsigned(n.typ), $n.typ
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
discard """
|
||||||
|
output: '''uint'''
|
||||||
|
"""
|
||||||
|
|
||||||
# Tests unsigned literals and implicit conversion between uints and ints
|
# Tests unsigned literals and implicit conversion between uints and ints
|
||||||
# Passes if it compiles
|
# Passes if it compiles
|
||||||
|
|
@ -43,3 +46,12 @@ block t4176:
|
||||||
var yyy: uint8 = 0
|
var yyy: uint8 = 0
|
||||||
yyy = yyy - 127
|
yyy = yyy - 127
|
||||||
doAssert type(yyy) is uint8
|
doAssert type(yyy) is uint8
|
||||||
|
|
||||||
|
# bug #13661
|
||||||
|
|
||||||
|
proc fun(): uint = cast[uint](-1)
|
||||||
|
const x0 = fun()
|
||||||
|
|
||||||
|
echo typeof(x0)
|
||||||
|
|
||||||
|
discard $x0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue