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

A value of type 'int' can't be assigned to a parameter of type 'FutureOr<int>'. #35612

Open
Keksinautin opened this Issue Jan 9, 2019 · 4 comments

Comments

Projects
None yet
5 participants
@Keksinautin
Copy link

Keksinautin commented Jan 9, 2019

In this code

import 'dart:async';

class A {
  final FutureOr<int> a;
  
  const A({this.a: 2});
}

void main() async {
  final b = const A(); // Here we have an error;
  ///But in this case it works well
  //final b = new A();
  
  print(b.a);
}

I have a error: A value of type 'int' can't be assigned to a parameter of type 'FutureOr<int>'.
I think this is a very strange result.

https://gist.github.com/Keksinautin/5366adf409b6762440cdf3c60ab5404b

  • Dart SDK Version (dart --version): 2.1.0
@vsmenon

This comment has been minimized.

Copy link
Member

vsmenon commented Jan 9, 2019

I can repro this with the dartanalyzer. If I run the above directly on the dart VM, it works fine.

@lrhn lrhn added the type-bug label Jan 10, 2019

@stereotype441

This comment has been minimized.

Copy link
Member

stereotype441 commented Jan 10, 2019

Marking as P1 since this seems like a pretty fundamental type system problem (possibly affecting soundness). If we investigate and find that it only fails in rare corner cases, we may downgrade to P2.

@bwilkerson

This comment has been minimized.

Copy link
Member

bwilkerson commented Jan 10, 2019

Makes me wonder whether the code I added to unwrap FutureOr in https://dart-review.googlesource.com/c/sdk/+/88741 needed to be added to the assignability testing methods.

@bwilkerson

This comment has been minimized.

Copy link
Member

bwilkerson commented Jan 10, 2019

After looking more closely at the original case, it seems more likely to me that the bug is in the constant evaluation engine, which would somewhat limit the impact of the bug.

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