Skip to content

Crash (Debug Failure) in Nightly when checking unreachable code in highly malformed sourceΒ #62912

@na7ure-a

Description

@na7ure-a

πŸ”Ž Search Terms

Debug Failure. Expected -1 >= 0

assertDiagnosticLocation

checkSourceElementUnreachable

compiler crash nightly

πŸ•— Version & Regression Information

Observed in: TypeScript Nightly
Does not occur in: 5.7.3, 5.8.3, 5.9.3

⏯ Playground Link

(https://www.typescriptlang.org/zh/play/?allowJs=true&target=7&outFile=true&ts=6.0.0-dev.20251219#code/KYDwDg9gTgLgBAQwM4E8B2BjOAzArpmASwjUSigRQDEoIBbAQVUwB4AVAPgApl0MBJGMAoAjADbAAhAC44TPoOEJxwdhwCUsgAq06hJKrYBtALoc4AbwCwAKDj24GEkngRc8ALxxTAblsOcaEQAdwRCeC4nNBc4ADc4CGxEZgEhUQl1S38AhzcYADowXCQACx5Q8Lj1PzsHAF9s+yhgGFwoUjyauqA)

πŸ’» Code

export async function arrayFromAsync<T>(asyncIterable!: AsyncIterable<T>): Promise<T[]> {
    const out = [];
    for await (const v of asyncIterable) {
        out.push(await v);
    }
    return out;
}

πŸ™ Actual behavior

.\ts-versions\nightly\node_modules.bin\tsc.cmd --ignoreConfig .\test-async-array.ts
D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib_tsc.js:123191
throw e;
^

Error: Debug Failure. Expected -2 >= 0
at assertDiagnosticLocation (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib_tsc.js:13878:9)
at createFileDiagnostic (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib_tsc.js:17717:3)
at checkSourceElementUnreachable (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib_tsc.js:86649:74)
at checkSourceElementWorker (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib_tsc.js:86427:11)
at checkSourceElement (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib_tsc.js:86396:7)
at forEach (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib_tsc.js:32:22)
at checkSourceFileWorker (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib_tsc.js:86866:7)
at checkSourceFile (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib_tsc.js:86825:69)
at checkSourceFileWithEagerDiagnostics (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib_tsc.js:86952:5)
at D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib_tsc.js:86974:46

Node.js v22.19.0

πŸ™‚ Expected behavior

The compiler should emit standard syntax errors (e.g., TS1005: ',' expected) and terminate gracefully without a "Debug Failure" crash, as it does in version 5.9.3.

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions