Skip to content

compiler exception: "Too many nodes written to output" #12961

Closed

Description

TypeScript Version: 2.1.4

Code

// A *self-contained* demonstration of the problem follows...
export class Test  {
    constructor() {

        let outerArray: Array<number> = [1, 2, 3];
        let innerArray: Array<number> = [1, 2, 3];

        for (let outer of outerArray)
            for (let inner of innerArray) {
                this.aFunction((newValue, oldValue) => {
                    console.log(`${outer} ${inner} ${newValue}`);
                });
            }
    }

    public aFunction(func: (newValue: any, oldValue: any) => void): void {
    }
}

tsconfig looks like this:

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

Expected behavior:
Should compile

Actual behavior:
The typescript compiler (tsc.exe) fails on an assertion, throwing the following exception:

Error: Debug Failure. False expression: Too many nodes written to output.
    at Object.assert (...\npm\node_modules\typescript\lib\tsc.js:1794:23)
    at extractSingleNode (...\npm\node_modules\typescript\lib\tsc.js:37059:15)
    at Object.visitNode (...\npm\node_modules\typescript\lib\tsc.js:36736:54)
    at convertIterationStatementBodyIfNecessary (...\npm\node_modules\typescript\lib\tsc.js:41071:31)
    at visitForOfStatement (...\npm\node_modules\typescript\lib\tsc.js:40912:20)
    at visitJavaScript (...\npm\node_modules\typescript\lib\tsc.js:40185:28)
    at visitorWorker (...\npm\node_modules\typescript\lib\tsc.js:40113:24)
    at dispatcher (...\npm\node_modules\typescript\lib\tsc.js:40034:19)
    at saveStateAndInvoke (...\npm\node_modules\typescript\lib\tsc.js:40052:27)
    at visitor (...\npm\node_modules\typescript\lib\tsc.js:40029:20)

Activity

  1. dkent600 commented on Dec 15, 2016

    @dkent600
    Author

    Error goes away if you set "target" to "es6"

  2. changed the title [-]compile error: "Too many nodes written to output"[/-] [+]compiler exception: "Too many nodes written to output"[/+] on Dec 15, 2016
  3. dkent600 commented on Dec 15, 2016

    @dkent600
    Author

    Error also goes away if you use regular javascript for loops, like:

    for (let i = 0; i < outerArray.length; i++)
          for (let j = 0; j < innerArray.length; j++)
    

    This is a work-around

  4. locked and limited conversation to collaborators on Jun 19, 2018
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

    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