Skip to content
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

LibJS: Yield looses scheduled/saved exceptions #23932

Open
Hendiadyoin1 opened this issue Apr 11, 2024 · 0 comments
Open

LibJS: Yield looses scheduled/saved exceptions #23932

Hendiadyoin1 opened this issue Apr 11, 2024 · 0 comments
Labels
bug Something isn't working has-repro We have a way to reproduce this bug.

Comments

@Hendiadyoin1
Copy link
Contributor

Reproducer (js test):

function* g() {
    try {
        throw 1;
    } finally {
        yield 0;
    }
}

a = g();
console.log(a.next()); // { "value": 0, "done": false } from the finalizer
expect(a.next).toThrow();

Cause:
Yield::execute_impl calls interpreter.do_return(value) which clears the current exception, which means the finally will not pick it up when execution continues.
But not clearing the exception would instead shadow the return value and bubble up the exception on the first iteration,
so we need to find a way to save the exception in the generator state and restore in on re-entry

@Hendiadyoin1 Hendiadyoin1 added bug Something isn't working has-repro We have a way to reproduce this bug. labels Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working has-repro We have a way to reproduce this bug.
Projects
Status: No status
Development

No branches or pull requests

1 participant