-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Dart2js throw/catch bug #53082
Comments
Thanks for filing this and attaching a simple reproduction! The issue here is a scoping issue in the way we're handling a non-async catch block within an async catch block. More specifically it's causing references to the inner catch variable to be overwritten by the references to the outer one. Therefore when we try to do the I have a fix in progress. But if you need a temporary workaround the bug can be avoided by making the inner try/catch async:
|
This also happens if |
That's actually an interesting case. |
If that ends up throwing a |
We generally don't specify anything about values which are not Dart values, or about things that cannot happen within the language, it's up to the individual backends to make any value appear to be a Dart value (subtype of I think it is reasonable for web compilers to treat any JS object which is not a Dart object, as being instances of |
Another option, if you want to avoid |
There are lots of places in the SDK, and the async API, where we assume that a caught value is not We could allow But it probably means that everybody will start to defensively write I'd prefer that on the web, we either just don't catch |
The latter would be acceptable. The former would make it extremely hard to work with JS code that involves callbacks. |
The following code handles nested throws and catches incorrectly in dart2js:
The Dart VM correctly prints:
When compiled with dart2js and run in Node.js or a browser, this incorrectly prints:
The text was updated successfully, but these errors were encountered: