Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

For loop variable type inference doesn't always work correctly #21

Closed
leafpetersen opened this issue Jan 9, 2015 · 2 comments
Closed

Comments

@leafpetersen
Copy link
Contributor

We should infer that i has type int here.

  for (var i = 0; i < 10; i++) {
    int j = /*info:DownCast should be pass*/i + 1;
  }

We seem to do this sometimes, not sure why it doesn't happen here - I think maybe the inference is happening but not getting propagated?

@vsmenon
Copy link
Contributor

vsmenon commented Feb 27, 2015

We appear not to handle for loops of this form. From DDC rules.dart:

// t must be an InterfaceType.
List<DartType> typeArguments = (t as InterfaceType).typeArguments;
for (var typeArgument in typeArguments) {
  if (!typeArgument.isDynamic) return false;
}

We're reporting the call to isDynamic as a dinvoke - we should infer that typeArgument is a DartType, but we are not.

@vsmenon vsmenon reopened this Feb 27, 2015
@jmesserly jmesserly removed their assignment Mar 19, 2015
@vsmenon vsmenon self-assigned this Mar 30, 2015
@vsmenon
Copy link
Contributor

vsmenon commented Mar 31, 2015

Fixed now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants