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

analyzer / cfe inconsistency on inferring dynamic vs Object #33324

Closed
vsmenon opened this issue Jun 4, 2018 · 4 comments
Closed

analyzer / cfe inconsistency on inferring dynamic vs Object #33324

vsmenon opened this issue Jun 4, 2018 · 4 comments
Assignees
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). P1 A high priority bug; for example, a single project is unusable or has many test failures
Milestone

Comments

@vsmenon
Copy link
Member

vsmenon commented Jun 4, 2018

The following fails statically with ddk (Error: The getter 'length' isn't defined for the class 'dart.core::Object'), but passes with ddc. If I print l.runtimeType, I get List<dynamic> with ddc and List<Object> with ddk.

void main() {
  Function f = (x) => x;
  var l = ["hello"].map(f).toList();
  l.add(42);
  print(l.first.length);
}

Filing on language to determine correct behavior.

@vsmenon vsmenon added the area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). label Jun 4, 2018
@leafpetersen
Copy link
Member

Another example: this code

void main() {
  dynamic f;
  List x;
  var a = x.map(f);
  int b = a;
}

Produces an error indicating that a is being inferred as Iterable<Object>. I suspect that the greatest closure computation is being done filling in with Object instead of dynamic. For this example, the downwards context on f is dynamic -> ? so the choice of what to fill in for ? in the greatest closure computation would result in Iterable<Object> or Iterable<dynamic> for Object/dynamic respectively.

@kmillikin kmillikin added the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label Jun 6, 2018
@kmillikin
Copy link

This issue breaks dart2js on Google's tests. A workaround has been committed but it will affect other users so I'm giving it a high priority to figure out what's going on, how easy it is to change, and what other effects that will have.

@kmillikin kmillikin added the P1 A high priority bug; for example, a single project is unusable or has many test failures label Jun 6, 2018
@chloestefantsova
Copy link
Contributor

A bit of context for the fix. Absence of handling of defaultType in some Kernel visitors resulted in some mistakes in distinguishing between omitted bounds and Object provided explicitly for the bounds. In its turn, it resulted in more type variables being marked as having explicit Object as their bound. It was exactly the case for the examples above: Object was provided because it was assumed the explicit bound of the type variable provided by the programmer.

@keertip keertip added this to the Dart2Stable milestone Jun 8, 2018
@keertip
Copy link
Contributor

keertip commented Jun 8, 2018

Thanks for the fix! Came across another test failure due to this.

@jensjoha jensjoha added this to Verify Fixed in Dart Front End Jun 26, 2018
@kmillikin kmillikin moved this from Verify Fixed to Done in Dart Front End Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
Development

No branches or pull requests

5 participants