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

Strong mode allows iterable to be assigned to list #26619

Closed
manuelF opened this issue Jun 4, 2016 · 2 comments
Closed

Strong mode allows iterable to be assigned to list #26619

manuelF opened this issue Jun 4, 2016 · 2 comments

Comments

@manuelF
Copy link

manuelF commented Jun 4, 2016

void main() {
  List<String> f = ['a', 'b']
  List<String> res = f.map((x) => x + 'aa');
  print(res)
}

$ dartanalyzer --strong file.dart
No issues found

$ dart file.dart
(aaa, baa)

$ dart --checked file.dart
type 'MappedListIterable' is not a subtype of type 'List' of 'res'

Shouldn't this at least produce a strong mode warning? Types are clearly not assignable.

@zoechi
Copy link
Contributor

zoechi commented Jun 4, 2016

It does complain about missing semicolons though ;-) https://dartpad.dartlang.org/926c7d2430072eb7eacf72ea907a1f1f (including missing ;)

@leafpetersen
Copy link
Member

This is potentially a valid downcast given the existing variance rules, and so we allow it. I hope to get an opt in flag for disabling these implicit downcasts implemented shortly. Closing this as a duplicate of #26583 which tracks that feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants