fixes #5216
This commit is contained in:
parent
376f6efa80
commit
68617adb91
2 changed files with 25 additions and 5 deletions
|
|
@ -216,24 +216,24 @@ proc getIntervalType*(m: TMagic, n: PNode): PType =
|
||||||
if b.kind in ordIntLit:
|
if b.kind in ordIntLit:
|
||||||
let x = b.intVal|+|1
|
let x = b.intVal|+|1
|
||||||
if (x and -x) == x and x >= 0:
|
if (x and -x) == x and x >= 0:
|
||||||
result = makeRange(a.typ, 0, b.intVal)
|
result = makeRange(n.typ, 0, b.intVal)
|
||||||
of mModU:
|
of mModU:
|
||||||
let a = n.sons[1]
|
let a = n.sons[1]
|
||||||
let b = n.sons[2]
|
let b = n.sons[2]
|
||||||
if b.kind in ordIntLit:
|
if b.kind in ordIntLit:
|
||||||
if b.intVal >= 0:
|
if b.intVal >= 0:
|
||||||
result = makeRange(a.typ, 0, b.intVal-1)
|
result = makeRange(n.typ, 0, b.intVal-1)
|
||||||
else:
|
else:
|
||||||
result = makeRange(a.typ, b.intVal+1, 0)
|
result = makeRange(n.typ, b.intVal+1, 0)
|
||||||
of mModI:
|
of mModI:
|
||||||
# so ... if you ever wondered about modulo's signedness; this defines it:
|
# so ... if you ever wondered about modulo's signedness; this defines it:
|
||||||
let a = n.sons[1]
|
let a = n.sons[1]
|
||||||
let b = n.sons[2]
|
let b = n.sons[2]
|
||||||
if b.kind in {nkIntLit..nkUInt64Lit}:
|
if b.kind in {nkIntLit..nkUInt64Lit}:
|
||||||
if b.intVal >= 0:
|
if b.intVal >= 0:
|
||||||
result = makeRange(a.typ, -(b.intVal-1), b.intVal-1)
|
result = makeRange(n.typ, -(b.intVal-1), b.intVal-1)
|
||||||
else:
|
else:
|
||||||
result = makeRange(a.typ, b.intVal+1, -(b.intVal+1))
|
result = makeRange(n.typ, b.intVal+1, -(b.intVal+1))
|
||||||
of mDivI, mDivU:
|
of mDivI, mDivU:
|
||||||
binaryOp(`|div|`)
|
binaryOp(`|div|`)
|
||||||
of mMinI:
|
of mMinI:
|
||||||
|
|
|
||||||
20
tests/arithm/tand.nim
Normal file
20
tests/arithm/tand.nim
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
discard """
|
||||||
|
output: '''int32
|
||||||
|
int32
|
||||||
|
1280
|
||||||
|
1280'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #5216
|
||||||
|
|
||||||
|
import typetraits
|
||||||
|
|
||||||
|
echo(name type((0x0A'i8 and 0x7F'i32) shl 7'i32))
|
||||||
|
|
||||||
|
let i8 = 0x0A'i8
|
||||||
|
echo(name type((i8 and 0x7F'i32) shl 7'i32))
|
||||||
|
|
||||||
|
echo((0x0A'i8 and 0x7F'i32) shl 7'i32)
|
||||||
|
|
||||||
|
let ii8 = 0x0A'i8
|
||||||
|
echo((ii8 and 0x7F'i32) shl 7'i32)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue