Skip to content

Fix control flow analysis for property initializers#8970

Merged
ahejlsberg merged 2 commits into
masterfrom
propertyControlFlow
Jun 7, 2016
Merged

Fix control flow analysis for property initializers#8970
ahejlsberg merged 2 commits into
masterfrom
propertyControlFlow

Conversation

@ahejlsberg
Copy link
Copy Markdown
Member

Fixes #8967.

Comment thread src/compiler/checker.ts
function getControlFlowContainer(node: Node): Node {
while (true) {
node = node.parent;
if (isFunctionLike(node) || node.kind === SyntaxKind.ModuleBlock || node.kind === SyntaxKind.SourceFile || node.kind === SyntaxKind.PropertyDeclaration) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this cover computed properties?

const LANG = "German";
class WurstLanguage {
    [LANG]() {
    }
}

Maybe the class itself should be a control flow container.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually, it should work since the parent will be a method declaration with a computed property name. It still might be worth adding as a test.

@RyanCavanaugh
Copy link
Copy Markdown
Member

👍

@ahejlsberg ahejlsberg merged commit 52d8a78 into master Jun 7, 2016
@mhegazy mhegazy deleted the propertyControlFlow branch June 7, 2016 00:05
@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