-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Guard against recursion in inferTypeForHomomorphicMappedType #38224
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
Conversation
@typescript-bot test this |
Heya @ahejlsberg, I've started to run the extended test suite on this PR at 8648986. You can monitor the build here. |
Heya @ahejlsberg, I've started to run the parallelized community code test suite on this PR at 8648986. You can monitor the build here. |
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 8648986. You can monitor the build here. |
Test runs all appear to be clean (issues are preexisting conditions). |
@@ -18267,12 +18268,16 @@ namespace ts { | |||
* variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for). | |||
*/ | |||
function inferTypeForHomomorphicMappedType(source: Type, target: MappedType, constraint: IndexType): Type | undefined { | |||
if (inInferTypeForHomomorphicMappedType) { | |||
return undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to cache this inference failure, as in invokeOnce
, so if it's attempted again on the same types outside the same recursive context (but during the same traversal) we still refuse to perform the secondary inference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. In the general case this function is never recursive. The only code paths that could recur are special cases for array and tuple types, so we're talking something that happens very rarely. I think this simple solution is fine.
Fixes #38198.