mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 20:17:42 +00:00
* 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:
@@ -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])
|
||||
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user