From ecf9efa3977f95aed5229ab79cd6ac4799a32a4c Mon Sep 17 00:00:00 2001 From: metagn Date: Thu, 30 Mar 2023 16:34:42 +0300 Subject: 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 --- doc/manual.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'doc') 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 --------------- -- cgit 1.4.1-2-gfad0