fixes 10697 [backport]
This commit is contained in:
parent
315d438677
commit
257965e105
2 changed files with 16 additions and 4 deletions
|
|
@ -519,6 +519,7 @@ proc binaryUintExpr(p: PProc, n: PNode, r: var TCompRes, op: string,
|
||||||
r.res = "$1 = (($5 $2 $3) $4)" % [a, rope op, y.rdLoc, trimmer, tmp]
|
r.res = "$1 = (($5 $2 $3) $4)" % [a, rope op, y.rdLoc, trimmer, tmp]
|
||||||
else:
|
else:
|
||||||
r.res = "(($1 $2 $3) $4)" % [x.rdLoc, rope op, y.rdLoc, trimmer]
|
r.res = "(($1 $2 $3) $4)" % [x.rdLoc, rope op, y.rdLoc, trimmer]
|
||||||
|
r.kind = resExpr
|
||||||
|
|
||||||
proc ternaryExpr(p: PProc, n: PNode, r: var TCompRes, magic, frmt: string) =
|
proc ternaryExpr(p: PProc, n: PNode, r: var TCompRes, magic, frmt: string) =
|
||||||
var x, y, z: TCompRes
|
var x, y, z: TCompRes
|
||||||
|
|
@ -1912,13 +1913,13 @@ proc genMagic(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
of mHigh:
|
of mHigh:
|
||||||
unaryExpr(p, n, r, "", "($1 != null ? ($2.length-1) : -1)")
|
unaryExpr(p, n, r, "", "($1 != null ? ($2.length-1) : -1)")
|
||||||
of mInc:
|
of mInc:
|
||||||
if n[1].typ.skipTypes(abstractRange).kind in tyUInt .. tyUInt64:
|
if n[1].typ.skipTypes(abstractRange).kind in {tyUInt..tyUInt64}:
|
||||||
binaryUintExpr(p, n, r, "+", true)
|
binaryUintExpr(p, n, r, "+", true)
|
||||||
else:
|
else:
|
||||||
if optOverflowCheck notin p.options: binaryExpr(p, n, r, "", "$1 += $2")
|
if optOverflowCheck notin p.options: binaryExpr(p, n, r, "", "$1 += $2")
|
||||||
else: binaryExpr(p, n, r, "addInt", "$1 = addInt($3, $2)")
|
else: binaryExpr(p, n, r, "addInt", "$1 = addInt($3, $2)")
|
||||||
of ast.mDec:
|
of ast.mDec:
|
||||||
if n[1].typ.skipTypes(abstractRange).kind in tyUInt .. tyUInt64:
|
if n[1].typ.skipTypes(abstractRange).kind in {tyUInt..tyUInt64}:
|
||||||
binaryUintExpr(p, n, r, "-", true)
|
binaryUintExpr(p, n, r, "-", true)
|
||||||
else:
|
else:
|
||||||
if optOverflowCheck notin p.options: binaryExpr(p, n, r, "", "$1 -= $2")
|
if optOverflowCheck notin p.options: binaryExpr(p, n, r, "", "$1 -= $2")
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ discard """
|
||||||
output: '''ABCDC
|
output: '''ABCDC
|
||||||
1
|
1
|
||||||
14
|
14
|
||||||
ok'''
|
ok
|
||||||
|
1'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -34,4 +35,14 @@ when true:
|
||||||
|
|
||||||
a.setLen(0)
|
a.setLen(0)
|
||||||
|
|
||||||
echo "ok"
|
echo "ok"
|
||||||
|
|
||||||
|
# bug #10697
|
||||||
|
proc test2 =
|
||||||
|
var val = uint16(0)
|
||||||
|
var i = 0
|
||||||
|
if i < 2:
|
||||||
|
val += uint16(1)
|
||||||
|
echo int(val)
|
||||||
|
|
||||||
|
test2()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue