Add support for captured block scoped bindings#7693
Merged
Conversation
| const savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; | ||
|
|
||
| const savedConvertedLoopState = convertedLoopState; | ||
| if (nodeStartsNewLexicalEnvironment(node) || isClassLike(node)) { |
Contributor
There was a problem hiding this comment.
What about an arrow function in a computed property name or extends clause of a class?
Contributor
Author
|
Good point |
| onBeforeVisitNode(node); | ||
| const savedConvertedLoopState = convertedLoopState; | ||
| if (nodeStartsNewLexicalEnvironment(node)) { | ||
| // don't treat content of nodes that start new lexical environment or class-like nodes as part of converted loop copy |
Contributor
There was a problem hiding this comment.
This comment may now be incorrect.
How do we want to handle captured block scope bindings for initializers?
let ar = [];
for (let i = 0; i < 2; i++) {
ar.push(class { x = i; });
}
console.log(new ar[0]().x); // should this be 0 or 2?
console.log(new ar[1]().x); // should this be 1 or 2?
Contributor
Author
There was a problem hiding this comment.
comment is fixed. Re initializers, I think this code should be equivalent to
"use strict"
let ar = [];
for (let i = 0; i < 2; i++) {
ar.push(class { x: number; constructor() { this.x=i }; });
}
console.log(new ar[0]().x); // should be 0
console.log(new ar[1]().x); // should be 1old emitter does not support this either so I'll file it as a separate issue that should be fixed
Contributor
|
👍 |
| nodeIsSynthesized(statements[0]) || | ||
| rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile) | ||
| ); | ||
| if (emitAsSingleStatement) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
// cc @rbuckton