Skip to content

[Master] Fix 13893: Fix runtime crash when class is used before declaration#14307

Merged
yuit merged 7 commits into
masterfrom
master-13893
Mar 21, 2017
Merged

[Master] Fix 13893: Fix runtime crash when class is used before declaration#14307
yuit merged 7 commits into
masterfrom
master-13893

Conversation

@yuit
Copy link
Copy Markdown
Contributor

@yuit yuit commented Feb 25, 2017

Fix #13893

Comment thread src/compiler/checker.ts
// we want to check for block-scoped
if (meaning & SymbolFlags.BlockScopedVariable) {
if (meaning & SymbolFlags.BlockScopedVariable ||
((meaning & SymbolFlags.Class || meaning & SymbolFlags.Enum) && (meaning & SymbolFlags.Value) === SymbolFlags.Value)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(meaning & SymbolFlags.Value) instead of (meaning & SymbolFlags.Value) === SymbolFlags.Value

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We have to check that the meaning flag is strictly looking for symbolFlags.value because other we will also issue an error when used in type location as well

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

U are correct. Sorry about that.

Copy link
Copy Markdown
Contributor

@mhegazy mhegazy left a comment

Choose a reason for hiding this comment

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

can you also add a test for:

function f() {
    new C2(); // OK
}    
class C2 { }

and

class C3 { 
    static intance = new C3();
}

@yuit yuit merged commit 990d2fa into master Mar 21, 2017
@yuit yuit deleted the master-13893 branch March 21, 2017 15:37
@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.

3 participants