Skip to content

Commit

Permalink
Fixed self-check crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Dec 28, 2023
1 parent 8030e75 commit 5d49f98
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2834,8 +2834,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return findAncestor(errorBindingElement, isBindingElement) !== findAncestor(declaration, isBindingElement) ||
declaration.pos < errorBindingElement.pos;
}
const rootDeclaration = getRootDeclaration(declaration) as Declaration;
if (rootDeclaration.kind !== SyntaxKind.VariableDeclaration) {
return true;
}
// or it might be illegal if usage happens before parent variable is declared (eg var [a] = a)
return isBlockScopedNameDeclaredBeforeUse(getAncestor(declaration, SyntaxKind.VariableDeclaration) as Declaration, usage);
return isBlockScopedNameDeclaredBeforeUse(rootDeclaration, usage);
}
else if (declaration.kind === SyntaxKind.VariableDeclaration) {
// still might be illegal if usage is in the initializer of the variable declaration (eg var a = a)
Expand Down

0 comments on commit 5d49f98

Please sign in to comment.