Skip to content

Compiler emits invalid IL for await in new Array arguments #3578

Closed

Description

@nickna

Compiled async generators emit invalid IL when an argument of a direct new Array call awaits.

async function* inspect() {
    try { yield new Array(await 1).length; }
    catch (error) { yield String(error); }
}
inspect().next().then(result => console.log(result.value), error => console.log(String(error)));

Node v22.23.2 and interpreted SharpTS print 1. Compiling with --no-tsconfig --noLib --compile repro.js --verify -o repro.dll fails verification in MoveNextAsync. The compiler build predating the #3552 follow-up changes reports ReturnEmpty, TryNonEmptyStack, and StackUnderflow. PR #3577 reports TryNonEmptyStack and StackOverflow for the same source.

The built-in Array constructor lowering leaves the argument array and index on the IL stack while evaluating the suspending argument. This predates the yield-operand exception guard for #3558. It also differs from #3565, whose saved assembly verifies and loses a synchronous guest exception during execution.

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