* 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:
Bung
2020-11-07 16:00:41 +08:00
committed by GitHub
parent 8f7a013cc7
commit c07807bedf
2 changed files with 7 additions and 1 deletions

View File

@@ -2269,7 +2269,7 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
initLocExpr(p, e[1], a)
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,
if underlying.kind == tyInt64: fun64[op] else: fun[op])

View File

@@ -0,0 +1,6 @@
discard """
outputsub: "Error: unhandled exception: over- or underflow [OverflowDefect]"
exitcode: "1"
"""
var x: distinct range[0..5]
dec(x)