Skip to content

Generator function + noImplicitAny triggers "Maximum call stack size exceeded" #21542

@xogeny

Description

@xogeny

TypeScript Version: 2.7.1 (and the current typescript@next as of Feb 1st, 2018)

**Search Terms: ** "Maximum call stack size exceeded" "checkExpression"

Code

The issue can be reproduced by trying to compile the following function with noImplicitAny set to true, (e.g., tsc foo.ts --noImplicitAny true).

export function* apply(proc, args, self) {
    var result;
    result = yield* applyInner(proc, args, self);
    while (isLambda(result) && result.thunk === true) {
        //     // trampoline loop - this gets invoked as a result of tail-call optimization
        //     // the function returned a tail-call thunk
        //     // unpack it, evaluate its arguments, and apply the tail call
        var next = yield* evaluate(result.body.procedure, result.input, result.environment);
        var evaluatedArgs = [];
        for (var ii = 0; ii < result.body.arguments.length; ii++) {
            // COMMENT THIS OUT AND THE STACK ISSUE GOES AWAY...
            evaluatedArgs.push(yield* evaluate(result.body.arguments[ii], result.input, result.environment));
        }
        result = yield* applyInner(next, evaluatedArgs, self);
    }
    return result;
}

Expected behavior:

To get at least an error message about what is wrong with the code.

Actual behavior:

/Users/mtiller/Source/OpenSource/ts-jest-sample/node_modules/typescript/lib/tsc.js:59890
                throw e;
                ^

RangeError: Maximum call stack size exceeded
    at checkPropertyAccessExpressionOrQualifiedName (/Users/mtiller/Source/OpenSource/ts-jest-sample/node_modules/typescript/lib/tsc.js:31759:28)
    at checkPropertyAccessExpression (/Users/mtiller/Source/OpenSource/ts-jest-sample/node_modules/typescript/lib/tsc.js:31752:20)
    at checkExpressionWorker (/Users/mtiller/Source/OpenSource/ts-jest-sample/node_modules/typescript/lib/tsc.js:34406:28)
    at checkExpression (/Users/mtiller/Source/OpenSource/ts-jest-sample/node_modules/typescript/lib/tsc.js:34356:42)
    at checkNonNullExpression (/Users/mtiller/Source/OpenSource/ts-jest-sample/node_modules/typescript/lib/tsc.js:31737:37)
    at checkPropertyAccessExpressionOrQualifiedName (/Users/mtiller/Source/OpenSource/ts-jest-sample/node_modules/typescript/lib/tsc.js:31759:28)
    at checkPropertyAccessExpression (/Users/mtiller/Source/OpenSource/ts-jest-sample/node_modules/typescript/lib/tsc.js:31752:20)
    at checkExpressionWorker (/Users/mtiller/Source/OpenSource/ts-jest-sample/node_modules/typescript/lib/tsc.js:34406:28)
    at checkExpression (/Users/mtiller/Source/OpenSource/ts-jest-sample/node_modules/typescript/lib/tsc.js:34356:42)
    at checkNonNullExpression (/Users/mtiller/Source/OpenSource/ts-jest-sample/node_modules/typescript/lib/tsc.js:31737:37)
error Command failed with exit code 1.

Playground Link: I tried. The playground app hangs as soon as I turn noImplicitAny on.

Related Issues: It looks like #12735 has similar characteristics. But that one was marked "Fixed" and closed over a year ago.

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