You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dart SDK Version: 2.1.0-dev.2.0
OS: Windows 10 (64 bit)
I am not 100% sure that this is not a duplicate of #34264, however on the firs glance these cases looks different.
The following code sample assign FutureOr variable (without type parameter specified) to int and then prints it:
import"dart:async";
main() {
FutureOr fff;
int i = fff;
print(i);
}
It passes both with analyzer and dart,no compiler errors and dart prints null value here.
I'm just wandering - should not it fail here in the strong mode?
Please note that if I change FutureOr to Future this test starts to fail both with analyzer and dart,, from my point of view this is expected behavior both for Future and FutureOr.
The text was updated successfully, but these errors were encountered:
FutureOr really means FutureOr<dynamic> (#33119), and FutureOr<dynamic> is a poor-man's "union type" of Future<dynamic> and dynamic. Of course, dynamic is statically assignable to int (with a runtime check), and it succeeds because everything is nullable right now (null is valid for anything).
/cc @lrhn if you have anything else to add, but I'll close for now.
In this case, should not case with Future (instead of FutureOr) in the example above statically pass in the same way? Now it fails both with analyzer and dart.
Dart SDK Version: 2.1.0-dev.2.0
OS: Windows 10 (64 bit)
I am not 100% sure that this is not a duplicate of #34264, however on the firs glance these cases looks different.
The following code sample assign
FutureOr
variable (without type parameter specified) toint
and then prints it:It passes both with analyzer and dart,no compiler errors and dart prints
null
value here.I'm just wandering - should not it fail here in the strong mode?
Please note that if I change
FutureOr
toFuture
this test starts to fail both with analyzer and dart,, from my point of view this is expected behavior both forFuture
andFutureOr
.The text was updated successfully, but these errors were encountered: