Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack overflow with type argument inference on infinitely recursive anonymous type #3451

Closed
JsonFreeman opened this issue Jun 9, 2015 · 3 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@JsonFreeman
Copy link
Contributor

This is very similar to #3309. It just uses type argument inference instead of assignability.

function foo<T>() {
    var z = foo<typeof y>();
    var y: {
        y2: typeof z
    };
    return y;
}


function bar<T>() {
    var z = bar<typeof y>();
    var y: {
        y2: typeof z;
    }
    return y;
}

var a = foo<number>();
var b = bar<number>();

function test<T>(x: typeof a): void { }
test(b);
@JsonFreeman JsonFreeman added the Bug A bug in TypeScript label Jun 9, 2015
@JsonFreeman JsonFreeman added this to the TypeScript 1.5.2 milestone Jun 9, 2015
@evil-shrike
Copy link

Hi.
As I mentioned in #2997 the fix didn't change anything in my case. I built deeplyNestedTypeArgumentInference branch, copied built/local into my project's typescript/bin and run:

D:\Work\R-n-D\XFW3_WebClient\Client\src>node ..\node_modules\typescript\bin\tsc --module amd --sourceMap -t es5 lib/ui/Part.ts
D:\Work\R-n-D\XFW3_WebClient\Client\node_modules\typescript\bin\tsc.js:0
(function (exports, require, module, __filename, __dirname) { var ts;
^
RangeError: Maximum call stack size exceeded
    at new Symbol (D:\Work\R-n-D\XFW3_WebClient\Client\node_modules\typescript\bin\tsc.js)
    at createSymbol (D:\Work\R-n-D\XFW3_WebClient\Client\node_modules\typescript\bin\tsc.js:11996:20)
    at instantiateSymbol (D:\Work\R-n-D\XFW3_WebClient\Client\node_modules\typescript\bin\tsc.js:15581:26)
    at instantiateList (D:\Work\R-n-D\XFW3_WebClient\Client\node_modules\typescript\bin\tsc.js:15475:33)
    at instantiateAnonymousType (D:\Work\R-n-D\XFW3_WebClient\Client\node_modules\typescript\bin\tsc.js:15594:33)
    at instantiateType (D:\Work\R-n-D\XFW3_WebClient\Client\node_modules\typescript\bin\tsc.js:15613:25)
    at instantiateList (D:\Work\R-n-D\XFW3_WebClient\Client\node_modules\typescript\bin\tsc.js:15475:33)
    at instantiateType (D:\Work\R-n-D\XFW3_WebClient\Client\node_modules\typescript\bin\tsc.js:15616:61)
    at getTypeOfInstantiatedSymbol (D:\Work\R-n-D\XFW3_WebClient\Client\node_modules\typescript\bin\tsc.js:14147:30)
    at getTypeOfSymbol (D:\Work\R-n-D\XFW3_WebClient\Client\node_modules\typescript\bin\tsc.js:14153:24)

@JsonFreeman
Copy link
Contributor Author

That is a shame. Unfortunately, without a longer stack trace or a sample that represents the issue, I'm out of ideas. If it is okay for me to see your original source code, I don't mind debugging on that.

@JsonFreeman JsonFreeman modified the milestones: TypeScript 1.6, TypeScript 1.5.2 Jun 10, 2015
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jun 12, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Jun 12, 2015

@evil-shrike can you verify that #3452 did indeed fix the issue?

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants