* fix #15706 Underflow not detected when using dec on distinct ranges * fix #15846 first, jsgen even doesn't care of range in this op
This commit is contained in:
parent
8f7a013cc7
commit
c07807bedf
2 changed files with 7 additions and 1 deletions
|
|
@ -2269,7 +2269,7 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||||
initLocExpr(p, e[1], a)
|
initLocExpr(p, e[1], a)
|
||||||
initLocExpr(p, e[2], b)
|
initLocExpr(p, e[2], b)
|
||||||
|
|
||||||
let ranged = skipTypes(e[1].typ, {tyGenericInst, tyAlias, tySink, tyVar, tyLent})
|
let ranged = skipTypes(e[1].typ, {tyGenericInst, tyAlias, tySink, tyVar, tyLent, tyDistinct})
|
||||||
let res = binaryArithOverflowRaw(p, ranged, a, b,
|
let res = binaryArithOverflowRaw(p, ranged, a, b,
|
||||||
if underlying.kind == tyInt64: fun64[op] else: fun[op])
|
if underlying.kind == tyInt64: fun64[op] else: fun[op])
|
||||||
|
|
||||||
|
|
|
||||||
6
tests/overflw/tdistinct_range.nim
Normal file
6
tests/overflw/tdistinct_range.nim
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
discard """
|
||||||
|
outputsub: "Error: unhandled exception: over- or underflow [OverflowDefect]"
|
||||||
|
exitcode: "1"
|
||||||
|
"""
|
||||||
|
var x: distinct range[0..5]
|
||||||
|
dec(x)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue