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 for infinitely recursive anonymous type #3309

Closed
JsonFreeman opened this issue May 30, 2015 · 0 comments · Fixed by #3316
Closed

Stack overflow for infinitely recursive anonymous type #3309

JsonFreeman opened this issue May 30, 2015 · 0 comments · Fixed by #3316
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@JsonFreeman
Copy link
Contributor

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>();
a = b;

Because the type parameter T is in scope when we encounter the anonymous type for y, a new type is created for the type of y. But each time foo/bar is called, yet a different type for y is created inside that call!

@ahejlsberg and I are leaning towards a solution that classifies such anonymous types (with type parameters in scope) as References, and give them targets. That way, isDeeplyNestedGeneric will bottom out and detect recursion.

We may need a similar mechanism in the display writer.

@JsonFreeman JsonFreeman added the Bug A bug in TypeScript label May 30, 2015
@ahejlsberg ahejlsberg self-assigned this May 30, 2015
@ahejlsberg ahejlsberg added this to the TypeScript 1.6 milestone May 30, 2015
@ahejlsberg ahejlsberg added the Fixed A PR has been merged for this issue label Jun 3, 2015
@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

Successfully merging a pull request may close this issue.

2 participants