mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 09:24:36 +00:00
* 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.
35 lines
518 B
Nim
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
|