summary refs log tree commit diff stats
path: root/doc
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-05-11 16:25:56 +0200
committerGitHub <noreply@github.com>2020-05-11 16:25:56 +0200
commit03c146cd93ba48f7e8cab05e6214c8675d0dd1f9 (patch)
tree748cc29daf2581a8fb336fac8565f3f150d06a08 /doc
parent517dd800f8e621aae0221f15c4ad7ad011c910b5 (diff)
downloadNim-03c146cd93ba48f7e8cab05e6214c8675d0dd1f9.tar.gz
do not track 'raise Defect' in the .raises: [] clause anymore (#14298)
* do not track 'raise Defect' in the .raises: [] clause anymore

* --panics:on maps 'raise Defect' to an unrecoverable fatal error

* make tests green again

* update the documentation too
Diffstat (limited to 'doc')
-rw-r--r--doc/manual.rst22
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/manual.rst b/doc/manual.rst
index 02ccace2c..6feb8aebb 100644
--- a/doc/manual.rst
+++ b/doc/manual.rst
@@ -4338,6 +4338,28 @@ Rules 1-2 ensure the following works:
 So in many cases a callback does not cause the compiler to be overly
 conservative in its effect analysis.
 
+Exceptions inheriting from ``system.Defect`` are not tracked with
+the ``.raises: []`` exception tracking mechanism. This is more consistent with the
+built-in operations. The following code is valid::
+
+.. code-block:: nim
+
+  proc mydiv(a, b): int {.raises: [].} =
+    a div b # can raise an DivByZeroDefect
+
+And so is::
+
+.. code-block:: nim
+
+  proc mydiv(a, b): int {.raises: [].} =
+    if b == 0: raise newException(DivByZeroDefect, "division by zero")
+    else: result = a div b
+
+
+The reason for this is that ``DivByZeroDefect`` inherits from ``Defect`` and
+with ``--panics:on`` Defects become unrecoverable errors.
+(Since version 1.4 of the language.)
+
 
 Tag tracking
 ------------