Closed Keksinautin closed 5 years ago
I can repro this with the dartanalyzer. If I run the above directly on the dart VM, it works fine.
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.
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.
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.
I tried to fix this, but hit once more type inference limitation.
test.dart
--------------
import 'test2.dart';
main() {
const C();
}
test2.dart
--------------
class C {
final List<int> values;
const C({this.values: const []});
}
Produces:
error: A value of type 'List<dynamic>' can't be assigned to a parameter of type 'List<int>'. (const_constructor_param_type_mismatch at [test] bin/test.dart:4)
This was fixed somewhere along the way. In dart 2.5.2, there are no warnings in the original example, nor in @scheglov's recent example with List<int>
. dart2js and the VM successfully execute as well.
It was fixed with summary2.
In this code
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 --version
): 2.1.0