-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
It's possible to use a single underscore as an enum value identifier (0.17.3) #7171
Comments
Why not? A single underscore can be an identifier. |
Just reported it in case it wasn't intended |
I thought let (x, _, _) = (1, 1, 1) # Would complain about redefinition if any other identifier was used
let _ = 1
let _ = 2 # Again, the compiler doesn't complain about redefinition
echo _ # Error: undeclared identifier: '_' |
Arraymancer depends on |
From what I can tell Arraymancer uses What should be disallowed is using Additionally, I think |
I tried to have a go again to remove When using generic return type in proc, identifier resolution happens before macro replacement which prevents from replacing |
Why not just use a different symbol in ArrayMancer? I used |
Yeah, |
I don't see the problem. Who accidentically uses |
That reasoning can be applied to a lot of semchecking though... Disallowing block:
const _ = 1
echo _ # Fine
block:
let _ = 1
echo _ # Error
block:
const _ = 1
block:
let _ = 2
echo _ # Prints 1
block: # My favorite
var i: int
var foo: int
template _(): var int = i
(_, foo) = (10, 10)
echo _ # Prints 10 |
How so? "Let's forbit the identifier brkkkk because it is ugly and could be used accidentically". |
The reasoning "who does that anyway", which is how I interpreted your remark, is overly optimistic. People do lots of things that might be bad in hindsight, although usually not accidentally. Also, the issue with x == (1, 2, _) # Only compare first two tuple elements
(_, foo) = (1, 2) # Destructuring assignment to already declared variable
const (_, foo) = (1, 2) # Destructuring assignment to const variable Extending the "magic" behavior of |
Indeed. By not forbidding it we are just begging for a can of worms to be opened at some point in the future. If it's possible then somebody will do it. People have often surprising habits. |
10 months later and it still hasn't caused us any real trouble. Closing. |
is valid code
The text was updated successfully, but these errors were encountered: