Skip to content

TypeError: Cannot read property 'kind' of undefined #6497

@andy-hanson

Description

@andy-hanson

The following code causes the compiler to crash:

function foo() {
    for (;;) {
        const a = 0
        switch (a) {
            case 0:
                return b => b(a)
        }
    }
}

The error is:

TypeError: Cannot read property 'kind' of undefined
    at convertLoopBody (/home/andy/git/TYPESCRIPT/node_modules/typescript/lib/tsc.js:27811:45)
    at emitLoop (/home/andy/git/TYPESCRIPT/node_modules/typescript/lib/tsc.js:27797:32)
    at emitForStatement (/home/andy/git/TYPESCRIPT/node_modules/typescript/lib/tsc.js:28011:17)
    at emitJavaScriptWorker (/home/andy/git/TYPESCRIPT/node_modules/typescript/lib/tsc.js:31428:32)
    at emitNodeWithoutSourceMap (/home/andy/git/TYPESCRIPT/node_modules/typescript/lib/tsc.js:31265:21)
    at emitNodeWithSourceMap (/home/andy/git/TYPESCRIPT/node_modules/typescript/lib/tsc.js:31259:21)
    at emitNodeConsideringCommentsOption (/home/andy/git/TYPESCRIPT/node_modules/typescript/lib/tsc.js:31250:21)
    at emit (/home/andy/git/TYPESCRIPT/node_modules/typescript/lib/tsc.js:31233:17)
    at emitLinesStartingAt (/home/andy/git/TYPESCRIPT/node_modules/typescript/lib/tsc.js:26271:21)
    at emitBlockFunctionBody (/home/andy/git/TYPESCRIPT/node_modules/typescript/lib/tsc.js:29114:21)

Tested on typescript 1.8.0-dev.20160114.

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions