-
Notifications
You must be signed in to change notification settings - Fork 214
[Wildcard Variables][spec] Treat all multiple underscores as wildcards? #3793
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
Personally I find this pretty compelling. I think we should go one step further, and add a lint that encourages people to rename an unused parameter called |
The most straightforward migration for a referenced
I think the proposed modification to the existing diagnostic in the first comment would be sufficient. We shouldn't need a new lint for this I think. |
@munificent has a good point: it's not that we want people to use So we don't need to support We could instead choose to just not allow The path of least resistance is to just allow |
I like that. We could say that We could lint all the underscore-only declared names with length at least 2, suggesting that As a convention, a developer or an organization might then decide that a specific situation justifies the usage of such names as "soft" wildcards: They do need to be accessed for some specific reasons, but the expectation is that they should be ignored except for that specific usage that prevented them from being real wildcards in the first place. One example could be that Another example could be that a wildcard is temporarily renamed to I think this scenario is more pragmatic than saying that " |
Which is what we are already saying, so that's also the easy path. (The lint + fix to
Or just allow |
Okay, so I see as a final decision: We don't see us making We want What we do want to change:
|
@lrhn mentioned that perhaps we should treat all of the multiple underscores as non-binding declarations as well.
This came up during an analyzer meeting while we were looking at how #unused-variable-warnings is already implemented in the analyzer, but with no unused variable warnings on
_
and__
,___
, etc.We would change this with the wildcard variables feature to have no unused variable warnings on only
_
, unless we would potentially see us having__
,___
, etc be non-binding in the future as well, which then maybe it would be useful to keep the behaviour as is?We should finalize whether we want to do that in this spec, or whether we want to do that at all in the future.
cc. @dart-lang/language-team @bwilkerson @stereotype441 @pq @scheglov @srawlins
Previous Discussion
Originally posted by @lrhn in #55661
Originally posted by @munificent in #55661
The text was updated successfully, but these errors were encountered: