Skip to content

Broken type inference - (list ?? anotherList) should be inferred as iterable #26079

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
natebosch opened this issue Mar 23, 2016 · 3 comments
Closed
Labels
closed-duplicate Closed in favor of an existing report legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@natebosch
Copy link
Member

(list ?? anotherList) is inferred as EfficientLength which is not iterable so the following snippet results in an analyzer warning:

for(var _ in (list ?? anotherList));

as does

var newList = list ?? anotherList;
for(var _ in newList);

but the analyzer can be appeased by

List newList = list ?? anotherList;
for(var _ in newList);

Ideally all 3 of these cases should work with no warnings.

@bwilkerson bwilkerson added legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Mar 23, 2016
@bwilkerson
Copy link
Member

Yep. That's the result of the way least-upper-bound is defined in the specification. Strong mode has a slightly different definition that tends to do what you want.

@natebosch
Copy link
Member Author

For the record: this behavior exists running in strong mode as well.

@bwilkerson bwilkerson reopened this Mar 24, 2016
@jmesserly jmesserly added the closed-duplicate Closed in favor of an existing report label Mar 24, 2016
@jmesserly
Copy link

Yup, we want to fix this in strong mode! Thanks for the report.
Merging this into #25821

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 legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants