-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
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.web-dart2js
Description
The following code shows different behavior on the Web and on the VM. It seems in dart2js case exception thrown from (*) is clobbering the exception which is currently in flight.
Future<void> something(int v) async {
await Future.delayed(Duration(milliseconds: 10));
throw StateError('error $v');
}
Stream<int> _readLoop() async* {
try {
while (true) {
yield 1;
await something(0);
}
} catch (e) {
throw StateError('converted');
} finally {
try {
await something(1); // (*)
} catch (e) {
print('Ignored: $e');
}
}
}
void main() async {
try {
await for (var _ in _readLoop()) {
}
} catch (e) {
print('Caught: $e');
}
}$ dart --version
Dart SDK version: 3.7.0-112.0.dev (dev) (Wed Nov 6 08:02:51 2024 -0800) on "macos_arm64"
$ dart test.dart
Ignored: Bad state: error 1
Caught: Bad state: converted
$ dart compile js test.dart
$ ~/.jsvu/v8 /Users/vegorov/src/flutter/flutter/bin/cache/dart-sdk/lib/_internal/js_runtime/lib/preambles/d8.js out.js
Ignored: Bad state: error 1
Caught: Bad state: error 1DDC might also have a problem with desugarring but of a different nature because in DartPad I get unhandled StateError.
/cc @natebiggs
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.web-dart2js