Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Self-referencing spread recursive loop#12808

Merged
sandersn merged 2 commits into
mastermicrosoft/TypeScript:masterfrom
self-referencing-spread-recursive-loopmicrosoft/TypeScript:self-referencing-spread-recursive-loopCopy head branch name to clipboard
Dec 12, 2016
Merged

Self-referencing spread recursive loop#12808
sandersn merged 2 commits into
mastermicrosoft/TypeScript:masterfrom
self-referencing-spread-recursive-loopmicrosoft/TypeScript:self-referencing-spread-recursive-loopCopy head branch name to clipboard

Conversation

@sandersn

@sandersn sandersn commented Dec 9, 2016

Copy link
Copy Markdown
Member

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

DanielRosenwasser commented Dec 9, 2016

Copy link
Copy Markdown
Member

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

sandersn commented Dec 9, 2016

Copy link
Copy Markdown
Member Author

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
Copy Markdown
Member Author

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

@mhegazy

mhegazy commented Dec 12, 2016

Copy link
Copy Markdown
Contributor

@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
Copy Markdown
Member Author

Ok, I ported it.

@mhegazy

mhegazy commented Dec 13, 2016

Copy link
Copy Markdown
Contributor

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

@sandersn

Copy link
Copy Markdown
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.