language icon indicating copy to clipboard operation
language copied to clipboard

[Wildcard Variables][spec] Late wildcard variables

Open kallentu opened this issue 1 month ago • 1 comments

(Pretty small thing, but I wanted to make sure we tracked this.)

What do we want to do with late wildcard variables? What does this combo even mean? Do we want to provide a warning on the late modifier?

late int _;
late int _ = 2;

cc. @dart-lang/language-team

kallentu avatar May 17 '24 22:05 kallentu

We don't have to special-case it. If we don't, it means precisely what it looks like: A late variable with no name to refer to it.

That makes it useless. No more useless than int _(int x) => x; or const _ = Banana();, and no less. We generally haven't tried to disallow places where declaring something names _ is "useless". That would require us to define "useless", which is always precarious.

lrhn avatar May 17 '24 23:05 lrhn

Note the overlap with https://github.com/dart-lang/language/issues/3798.

eernstg avatar May 19 '24 11:05 eernstg

Good call @eernstg. Didn't see that issue. Closing this one.

kallentu avatar May 20 '24 16:05 kallentu