Description
@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
Another thought: Maybe we should treat all of
__
,___
etc. as non-binding declarations too. It's not necessary, but I'm not sure I'd want someone to write__
as a name, just to not have it be non-binding, and still not give the thing a real name.It's a little iffy, because then they should probably work the same in patterns too. And that's an unrelated breaking change.
(Still think it would be prettier.)
Originally posted by @lrhn in #55661
I considered that when I was first writing the proposal. You're point about it being inconsistent with patterns is, I think, a good one.
Also, we ultimately want to get to a world where people don't use
__
,___
, etc. So I think scoping wildcards to only be a single_
helps us go in that direction.
Originally posted by @munificent in #55661