Skip to content

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

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

Merged
merged 7 commits into from
Mar 21, 2017

Conversation

yuit
Copy link
Contributor

@yuit yuit commented Feb 25, 2017

Fix #13893

@@ -1056,9 +1056,10 @@ namespace ts {
// block-scoped variable and namespace module. However, only when we
// try to resolve name in /*1*/ which is used in variable position,
// 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
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
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
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
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