-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
tuple destructuring doesn't always work with _
(underscore)
#18710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
_
(underscore)_
(underscore)
By Nim's definitions, a variable couldn't even start with "_". Look here. So, for me, the bug occurs in this situation: |
Not really, it's special, but assigning to it discards the value (so you can't really declare it), you can't use it in an expression or anything.
That doesn't make any sense. let _ = 42
# the following doesn't compile, since _ isn't a normal variable
# echo _ Now arguably |
Sorry, I didn't know the "_" functionality described here. |
|
Won't make the PR since it's new behavior but the patch for this is just skipping underscores here: Lines 141 to 142 in e68a6ea
|
* round out tuple unpacking assignment, support underscores fixes #18710 * fix test messages * use discard instead of continue Co-authored-by: Andreas Rumpf <[email protected]> --------- Co-authored-by: Andreas Rumpf <[email protected]>
* round out tuple unpacking assignment, support underscores fixes #18710 * fix test messages * use discard instead of continue Co-authored-by: Andreas Rumpf <[email protected]> --------- Co-authored-by: Andreas Rumpf <[email protected]> (cherry picked from commit 53d43e9)
Tuple desctructuring does not work with underscores if used outside of
var
section. Inside it it's OK, and that's confusing. It seems Nim sees_
as a special identifier that should be declared.Example
Current Output
Error: undeclared identifier: '_'
Expected Output
To work the same way as
(This was fixed at some stage, e.g. bug #2421)
Possible Solution
Additional Information
Checked with Nim 1.4 and Nim 1.5 devel.
The text was updated successfully, but these errors were encountered: