summary refs log tree commit diff stats
path: root/tests/effects/tstrict_effects_sort.nim
blob: 8928ed0d3907c24015450ebc50fc6d69fc88a979 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
discard """
  errormsg: "cmpE can raise an unlisted exception: Exception"
  line: 27
"""

{.push warningAsError[Effect]: on.}

{.experimental: "strictEffects".}

import algorithm

type
  MyInt = distinct int

var toSort = @[MyInt 1, MyInt 2, MyInt 3]

proc cmpN(a, b: MyInt): int =
  cmp(a.int, b.int)

proc harmless {.raises: [].} =
  toSort.sort cmpN

proc cmpE(a, b: MyInt): int {.raises: [Exception].} =
  cmp(a.int, b.int)

proc harmfull {.raises: [].} =
  toSort.sort cmpE