Files
Nim/tests/misc/tunsignedinc.nim
Jacek Sieka 7d6cbf290a Error -> Defect for defects (#13908)
* Error -> Defect for defects

The distinction between Error and Defect is subjective,
context-dependent and somewhat arbitrary, so when looking at an
exception, it's hard to guess what it is - this happens often when
looking at a `raises` list _without_ opening the corresponding
definition and digging through layers of inheritance.

With the help of a little consistency in naming, it's at least possible
to start disentangling the two error types and the standard lib can set
a good example here.
2020-04-28 19:56:01 +02:00

35 lines
518 B
Nim

block: # bug #2427
var x = 0'u8
dec x # OverflowDefect
x -= 1 # OverflowDefect
x = x - 1 # No error
doAssert(x == 253'u8)
block:
var x = 130'u8
x += 130'u8
doAssert(x == 4'u8)
block:
var x = 40000'u16
x = x + 40000'u16
doAssert(x == 14464'u16)
block:
var x = 4000000000'u32
x = x + 4000000000'u32
doAssert(x == 3705032704'u32)
block:
var x = 123'u16
x -= 125
doAssert(x == 65534'u16)
block t4175:
let i = 0u - 1u
const j = 0u - 1u
doAssert i == j
doAssert j + 1u == 0u