mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
fixes #23894
keeps it consistent with `inc`
(cherry picked from commit bd063113ec)
This commit is contained in:
@@ -602,7 +602,7 @@ proc binaryArithOverflow(p: BProc, e: PNode, d: var TLoc, m: TMagic) =
|
||||
# skipping 'range' is correct here as we'll generate a proper range check
|
||||
# later via 'chckRange'
|
||||
let t = e.typ.skipTypes(abstractRange)
|
||||
if optOverflowCheck notin p.options:
|
||||
if optOverflowCheck notin p.options or (m in {mSucc, mPred} and t.kind in {tyUInt..tyUInt64}):
|
||||
let res = "($1)($2 $3 $4)" % [getTypeDesc(p.module, e.typ), rdLoc(a), rope(opr[m]), rdLoc(b)]
|
||||
putIntoDest(p, d, e, res)
|
||||
else:
|
||||
|
||||
@@ -219,3 +219,9 @@ proc bug23223 = # bug #23223
|
||||
doAssert stuff == "hello"
|
||||
|
||||
bug23223()
|
||||
|
||||
block: # bug #23894
|
||||
let v = high(uint) div 2
|
||||
let s = v + 1 # 9223372036854775808
|
||||
let m = succ v
|
||||
doAssert s == m
|
||||
|
||||
Reference in New Issue
Block a user