Skip to content

Compiler exception: "Too many nodes written to output" #13664

@Samotorcan

Description

@Samotorcan

TypeScript Version: 2.1.5

Code

declare let doSomething;

for (let a1 of [])
    for (let a2 of a1.someArray)
        doSomething(() => a2);

tsconfig looks like this:

{
    "compilerOptions": {
        "moduleResolution": "node",
        "target": "es5"
    },
    "files": [
        "test.ts"
    ]
}

Expected behavior:
Should compile.

Actual behavior:
Typescript compiler fails on an assertion, throwing the following exception:

Error: Debug Failure. False expression: Too many nodes written to output.
    at Object.assert (...\built\local\tsc.js:2707:23)
    at extractSingleNode (...\built\local\tsc.js:38414:15)
    at Object.visitNode (...\built\local\tsc.js:38091:54)
    at convertForOfToFor (...\built\local\tsc.js:42367:36)
    at convertIterationStatementBodyIfNecessary (...\built\local\tsc.js:42440:40)
    at visitForOfStatement (...\built\local\tsc.js:42320:20)
    at visitJavaScript (...\built\local\tsc.js:41590:28)
    at visitorWorker (...\built\local\tsc.js:41518:24)
    at dispatcher (...\built\local\tsc.js:41439:19)
    at saveStateAndInvoke (...\built\local\tsc.js:41457:27)

The problem goes away if the first loop is written with curly brackets.

declare let doSomething;

for (let a1 of []) {
    for (let a2 of a1.someArray)
        doSomething(() => a2);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions