Skip to content

Type argument inference fix for infinitely recursive anonymous types #3452

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

Merged
merged 7 commits into from
Jun 12, 2015

Conversation

JsonFreeman
Copy link
Contributor

Type argument inference should use the same infrastructure as assignability when it comes to detecting infinite recursion in a type structure. This change makes type argument inference rely on the same isDeeplyNestedGeneric function.

Fixes #3451.

inferFromIndexTypes(source, target, IndexKind.String, IndexKind.String);
inferFromIndexTypes(source, target, IndexKind.Number, IndexKind.Number);
inferFromIndexTypes(source, target, IndexKind.String, IndexKind.Number);
depth--; }
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is with this brace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a white space management error

@JsonFreeman
Copy link
Contributor Author

@ahejlsberg Do you have any feedback on this?

@ahejlsberg
Copy link
Member

Overall, I like this unification. We used to stop after five levels of nesting during type inference, but now we'll go to ten levels. I doubt there are real world examples where this makes a difference in the quality of the inferences, but it certainly might impact performance (e.g. we'll spend time making the same inference ten times instead of five times). Thoughts? Perhaps we should pass the limit as a parameter so we can keep it at five for inference?

@JsonFreeman
Copy link
Contributor Author

Passing a limit parameter is an option. And I agree that the quality of the inference will not be impacted in realistic cases.

That said, if we are concerned about performance, and we think changing the 10 to a 5 will help, I actually think we should do it across the board, for assignability too. Assignability is way more common than type argument inference, and in fact, I think every round of type argument inference is followed by a round of assignability checking. So we'd get way more mileage if we did that change across the board, and we'd get to keep the limit consistent. I also don't think we would sacrifice much correctness if we change to 5 for assignability.

@ahejlsberg
Copy link
Member

Yeah, changing to 5 across the board is probably better. Let's do that.

JsonFreeman added a commit that referenced this pull request Jun 12, 2015
…ence

Type argument inference fix for infinitely recursive anonymous types
@JsonFreeman JsonFreeman merged commit 72783bc into master Jun 12, 2015
@JsonFreeman JsonFreeman deleted the deeplyNestedTypeArgumentInference branch June 12, 2015 21:11
@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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants