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

Self-referencing spread recursive loop #12808

Merged
merged 2 commits into from
Dec 12, 2016

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Dec 9, 2016

Fixes #12735

Use checkExpression in checkSpreadExpression, not checkExpressionCached. checkExpressionCached ignores ongoing control flow analysis, which causes the following loop to make the compiler recur infinitely:

// @noImplicitAny: true
let a = []
for (const x of []) {
    a = [...a]
}

An alternate fix would make checkExpressionCached not ignore control flow analysis in some situations, but that's a much more complicated fix, I think. @ahejlsberg, do you have an opinion on whether that or some other fix is feasible?

Not checkExpressionCached. checkExpressionCached ignores ongoing control
flow analysis, which causes the following loop to make the compiler
recur infinitely:

```ts
let a = []
for (const x of []) {
    a = [...a]
}
```
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Dec 9, 2016

Does checkExpressionCached document that it doesn't respect control flow analysis? Maybe it should be renamed so that other people don't incorrectly use it.

@sandersn
Copy link
Member Author

sandersn commented Dec 9, 2016

checkExpressionCached also interacts with contextual typing. Both interactions are documented in the function's comments, but not in its name. I can't think of a good name anyway ... checkExpressionCachedWithContextualTypingAndFreshControlFlow?

@sandersn
Copy link
Member Author

Oops, this fixes #12735. I got the bug number wrong initially.

@mhegazy
Copy link
Contributor

mhegazy commented Dec 12, 2016

@sandersn please port this change to release-2.1 as well.

@sandersn sandersn merged commit 65bb78d into master Dec 12, 2016
@sandersn sandersn deleted the self-referencing-spread-recursive-loop branch December 12, 2016 18:40
@mhegazy mhegazy mentioned this pull request Dec 12, 2016
@sandersn
Copy link
Member Author

Ok, I ported it.

@mhegazy
Copy link
Contributor

mhegazy commented Dec 13, 2016

never mind. i have a port already up: #12864

@sandersn
Copy link
Member Author

Sorry, I didn't see it until after I pushed . I wondered why I did t have merge conflicts with the new commits...

@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.

RangeError: Maximum call stack size exceeded in TS 2.1.4
4 participants