-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.dart2js-ddc-discrepancyWhen dev and production compilations have different semanticsWhen dev and production compilations have different semanticsweb-dev-compiler
Description
The following code has one case with an await and one that is synchronous. It should and does always execute the synchronous case but it does not execute synchronously as shown by the ordering of the elements in order.
If you replace the switch expression with a ternary expression, the execution appears to happen in the expected order.
import 'dart:async';
void main() async {
FutureOr<int> value = 3;
var order = <String>[];
run() async {
order.add('Before switch');
final result = switch (value) {
Future<int>() => await value,
int() => value,
};
print(result == 3); // Expected: 3
order.add('After switch');
}
var runFuture = run();
order.add('After run()');
await runFuture;
print(order); // Expected: ['Before switch', 'After switch', 'After run()']
}Metadata
Metadata
Assignees
Labels
area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.dart2js-ddc-discrepancyWhen dev and production compilations have different semanticsWhen dev and production compilations have different semanticsweb-dev-compiler