-
Notifications
You must be signed in to change notification settings - Fork 12.9k
[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
Conversation
@@ -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)) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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();
}
Fix #13893