Skip to content
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

[wildcards] produce a warning on late wildcard variables. #55905

Closed
Tracked by #55680
pq opened this issue Jun 3, 2024 · 1 comment
Closed
Tracked by #55680

[wildcards] produce a warning on late wildcard variables. #55905

pq opened this issue Jun 3, 2024 · 1 comment
Assignees
Labels
analyzer-warning Issues with the analyzer's Warning codes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-wildcard-variables Implementation of the wildcard variables feature P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@pq
Copy link
Member

pq commented Jun 3, 2024

Examples:

Initializing expression is essentially dead code:

int f() => throw StateError('unreachable');

void g() {
  late int _ = f();
  late final int _ = f();
}

Variable declaration is unnecessary (can't be accessed or assigned to):

void f() {
  late int _;
  late final int _;
}

Discussion: dart-lang/language#3798

@pq pq self-assigned this Jun 3, 2024
@pq pq added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-warning Issues with the analyzer's Warning codes P2 A bug or feature request we're likely to work on feature-wildcard-variables Implementation of the wildcard variables feature labels Jun 3, 2024
@srawlins srawlins added the type-enhancement A request for a change that isn't a bug label Jun 7, 2024
@pq pq changed the title [wildcards] produce a warning on wildcard variables. [wildcards] produce a warning on late wildcard variables. Jun 14, 2024
@pq
Copy link
Member Author

pq commented Jul 10, 2024

Similar to,

void f() {
  late int _;
  late final int _;
}

but without the late,

void f() {
  int? _;
  final int? _;
}

the _ declarations are equally dead/unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-warning Issues with the analyzer's Warning codes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-wildcard-variables Implementation of the wildcard variables feature P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants