Skip to content

Analyzer should warn when A<void> is assign to A<?> #34680

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

Closed
a14n opened this issue Oct 4, 2018 · 2 comments
Closed

Analyzer should warn when A<void> is assign to A<?> #34680

a14n opened this issue Oct 4, 2018 · 2 comments
Labels
closed-duplicate Closed in favor of an existing report

Comments

@a14n
Copy link
Contributor

a14n commented Oct 4, 2018

On sdk>=2.0 there should be a hint/error for things like:

void main() {
  List<String> l1 = List<void>(); // should be an error because it's an error at runtime
  List<String> l2 = <void>[]; // strangely there's already an error today
  List<dynamic> l3 = List<void>(); // OK for dynamic
}
@matanlurey matanlurey added the closed-duplicate Closed in favor of an existing report label Oct 4, 2018
@matanlurey
Copy link
Contributor

These are downcasts, and are legal in the language.

Otherwise, this is duplicate of #33372.

@MichaelRFairhurst
Copy link
Contributor

Also will drop in to say that this was intended to be illegal by dart 2 with "voidness preservation" (basically a form of illegal implicit downcasts that was on by default but limited to this case). Unfortunately we didn't have time to land it, but it may get a lint or be in dart 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

3 participants