Skip to content

"Debug Failure" with misplaced 'continue' and async/await #17875

@andyfischer

Description

@andyfischer

If the continue keyword is used outside of a loop, and there's an await on the other side of the conditional (see sample code below), this causes an ugly error.

TypeScript Version: 2.4.2

Code

function dummyPromise() {
    return new Promise((resolve, reject) => {});
}

async function func() {
    if (true) {
        continue;
    } else {
        await dummyPromise();
    }
}

Expected behavior:

This should print error TS1107: Jump target cannot cross function boundary. (this is usually the message when continue is wrongly used outside of a loop)

Actual behavior:

afischer-mba ~/ts-bug-report $ tsc -v
Version 2.4.2
afischer-mba ~/ts-bug-report $ tsc src/test.ts 
/usr/local/lib/node_modules/typescript/lib/tsc.js:55776
                throw e;
                ^

Error: Debug Failure. 
    at findContinueTarget (/usr/local/lib/node_modules/typescript/lib/tsc.js:48265:22)
    at transformAndEmitContinueStatement (/usr/local/lib/node_modules/typescript/lib/tsc.js:47796:25)
    at transformAndEmitStatementWorker (/usr/local/lib/node_modules/typescript/lib/tsc.js:47551:28)
    at transformAndEmitStatement (/usr/local/lib/node_modules/typescript/lib/tsc.js:47531:13)
    at transformAndEmitStatements (/usr/local/lib/node_modules/typescript/lib/tsc.js:47515:17)
    at transformAndEmitEmbeddedStatement (/usr/local/lib/node_modules/typescript/lib/tsc.js:47520:17)
    at transformAndEmitIfStatement (/usr/local/lib/node_modules/typescript/lib/tsc.js:47617:21)
    at transformAndEmitStatementWorker (/usr/local/lib/node_modules/typescript/lib/tsc.js:47541:28)
    at transformAndEmitStatement (/usr/local/lib/node_modules/typescript/lib/tsc.js:47531:13)
    at transformAndEmitStatements (/usr/local/lib/node_modules/typescript/lib/tsc.js:47515:17)

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions