Skip to content

Compiled async generator for-await value getter bypasses the local catch #3629

Closed

Description

@nickna
const iterable = {
    [Symbol.asyncIterator]() {
        return {
            next() { return { done: false, get value() { throw new Error('step'); } }; },
            return() { console.log('unexpected close'); return { done: true }; }
        };
    }
};
async function* run() {
    try { for await (const value of iterable) yield value; }
    catch (error) { yield error.message; }
}
run().next().then(result => console.log(result.value, result.done),
    error => console.log('rejected', error.message));

Node prints step false. On 72455db66, SharpTS compilation with --no-tsconfig --noLib --compile --verify passes IL verification, but the saved DLL prints rejected step.

The error from reading the iterator result's value should reach the generator's local catch. The emitted for await path reads value outside its exception router. Found while verifying #3614.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions