summary refs log tree commit diff stats
path: root/tests/effects
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-03-29 22:00:18 +0200
committerGitHub <noreply@github.com>2020-03-29 22:00:18 +0200
commit2a278f6eba5b154920177154bb48733268cacfc5 (patch)
tree33f37c25c099714899a96ac712a3908c1fc26c6e /tests/effects
parent06f8c5cb6f04319fd6ca6eafc496f3da882ab341 (diff)
downloadNim-2a278f6eba5b154920177154bb48733268cacfc5.tar.gz
'.push raises: []' now also affects proc types (#13776)
* '.push raises: []' now also affects proc types

* fixes the regression

* less disruptive bugfix

* another attempt
Diffstat (limited to 'tests/effects')
-rw-r--r--tests/effects/teffects1.nim23
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/effects/teffects1.nim b/tests/effects/teffects1.nim
index 6ca24d53e..3bd19f4ab 100644
--- a/tests/effects/teffects1.nim
+++ b/tests/effects/teffects1.nim
@@ -1,7 +1,13 @@
 discard """
-  errormsg: "can raise an unlisted exception: ref IOError"
+  errormsg: "type mismatch: got <proc (x: int): string{.noSideEffect, gcsafe, locks: 0.}> but expected 'MyProcType = proc (x: int): string{.closure.}'"
   file: "teffects1.nim"
-  line: 17
+  line: 38
+  cmd: "nim check $file"
+  nimout: '''teffects1.nim(22, 28) template/generic instantiation from here
+teffects1.nim(23, 13) Error: can raise an unlisted exception: ref IOError
+teffects1.nim(22, 29) Hint: 'IO2Error' is declared but not used [XDeclaredButNotUsed]
+teffects1.nim(38, 21) Error: type mismatch: got <proc (x: int): string{.noSideEffect, gcsafe, locks: 0.}> but expected 'MyProcType = proc (x: int): string{.closure.}'
+.raise effects differ'''
 """
 
 type
@@ -18,3 +24,16 @@ proc lier(): int {.raises: [IO2Error].} =
 
 proc forw: int =
   raise newException(IOError, "arg")
+
+{.push raises: [Defect].}
+
+type
+  MyProcType* = proc(x: int): string #{.raises: [ValueError, Defect].}
+
+proc foo(x: int): string {.raises: [ValueError].} =
+  if x > 9:
+    raise newException(ValueError, "Use single digit")
+  $x
+
+var p: MyProcType = foo
+{.pop.}