diff options
author | Oscar NihlgÄrd <oscarnihlgard@gmail.com> | 2019-08-20 17:39:49 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-08-20 17:39:49 +0200 |
commit | 4264e9576d0f3753dcff206fcff06217f2e70833 (patch) | |
tree | bb9d67fce9cf45766d722d41ff974179dac49035 /doc | |
parent | d00c8febeec15c4d1503d506474b24e7653eecc5 (diff) | |
download | Nim-4264e9576d0f3753dcff206fcff06217f2e70833.tar.gz |
Consider range type of runtime discrim [feature] (#11432)
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual.rst | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/doc/manual.rst b/doc/manual.rst index 0e4eb08a8..e1fb2fa59 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -1600,7 +1600,9 @@ statement. If possible values of the discriminator variable in a ``case`` statement branch are a subset of discriminator values for the selected object branch, the initialization is considered valid. This analysis only works for immutable discriminators of an ordinal type and disregards ``elif`` -branches. +branches. For discriminator values with a ``range`` type, the compiler +checks if the entire range of possible values for the discriminator value is +valid for the choosen object branch. A small example: @@ -1619,6 +1621,10 @@ A small example: else: echo "ignoring: ", unknownKind + # also valid, since unknownKindBounded can only contain the values nkAdd or nkSub + let unknownKindBounded = range[nkAdd..nkSub](unknownKind) + z = Node(kind: unknownKindBounded, leftOp: Node(), rightOp: Node()) + Set type -------- |