summary refs log tree commit diff stats
path: root/doc/manual.rst
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-02-23 11:49:21 +0100
committerAndreas Rumpf <rumpf_a@web.de>2019-02-23 11:49:29 +0100
commitf86835ce77f05133cdb8eeef0a7986a040a61954 (patch)
treead4bb1b69442b2743eb84ae41ec573fadd73064c /doc/manual.rst
parent71df1b060b272f9c1b6e5a0f393b3a319705cc70 (diff)
downloadNim-f86835ce77f05133cdb8eeef0a7986a040a61954.tar.gz
manual: document implicit type conversions involving 'range'; refs #10495
Diffstat (limited to 'doc/manual.rst')
-rw-r--r--doc/manual.rst14
1 files changed, 13 insertions, 1 deletions
diff --git a/doc/manual.rst b/doc/manual.rst
index 7b0a30f6a..a2d51cf08 100644
--- a/doc/manual.rst
+++ b/doc/manual.rst
@@ -2288,7 +2288,7 @@ A type ``a`` is **implicitly** convertible to type ``b`` iff the following
 algorithm returns true:
 
 .. code-block:: nim
-  # XXX range types?
+
   proc isImplicitlyConvertible(a, b: PType): bool =
     if isSubtype(a, b) or isCovariant(a, b):
       return true
@@ -2316,6 +2316,18 @@ algorithm returns true:
     of string:
       result = b == cstring
 
+
+Implicit conversions are also performed for Nim's ``range`` type
+constructor.
+
+Let ``a0``, ``b0`` of type ``T``.
+
+Let ``A = range[a0..b0]`` be the argument's type, ``F`` the formal
+parameter's type. Then an implicit conversion from ``A`` to ``F``
+exists if ``a0 >= low(F) and b0 <= high(F)`` and both ``T`` and ``F``
+are signed integers or if both are unsigned integers.
+
+
 A type ``a`` is **explicitly** convertible to type ``b`` iff the following
 algorithm returns true: