summary refs log tree commit diff stats
path: root/doc
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2023-03-30 16:34:42 +0300
committerGitHub <noreply@github.com>2023-03-30 15:34:42 +0200
commitecf9efa3977f95aed5229ab79cd6ac4799a32a4c (patch)
tree4416d5c0109d308f861afc6d43fb28a168bcc18f /doc
parent51ced0d68477e4d2ae5fa8183579922ec47cd318 (diff)
downloadNim-ecf9efa3977f95aed5229ab79cd6ac4799a32a4c.tar.gz
document general use of `_`, error message, fixes (#21584)
* document general use of `_`, error message, fixes

fixes #20687, fixes #21435

Documentation and changelog updated to clarify new universal behavior
of `_`. Also new error message for attempting to use `_`, new tests,
and fixes with overloadable symbols and
implicit generics.

* add test for #21435
Diffstat (limited to 'doc')
-rw-r--r--doc/manual.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/manual.md b/doc/manual.md
index 1fd35e7b3..850a04b0d 100644
--- a/doc/manual.md
+++ b/doc/manual.md
@@ -3076,6 +3076,19 @@ when they are declared. The only exception to this is if the `{.importc.}`
 pragma (or any of the other `importX` pragmas) is applied, in this case the
 value is expected to come from native code, typically a C/C++ `const`.
 
+Special identifier `_` (underscore)
+-----------------------------------
+
+The identifier `_` has a special meaning in declarations.
+Any definition with the name `_` will not be added to scope, meaning the
+definition is evaluated, but cannot be used. As a result the name `_` can be
+indefinitely redefined.
+
+  ```nim
+  let _ = 123
+  echo _ # error
+  let _ = 456 # compiles
+  ```
 
 Tuple unpacking
 ---------------