Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Rename getFunctionScope to a clearer name.
Browse files Browse the repository at this point in the history
  • Loading branch information
loganfsmyth committed Feb 2, 2018
1 parent c83996c commit 36c8222
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/workers/parser/visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function isNode(node?: Node, type: string): boolean {
return node ? node.type === type : false;
}
function getFunctionScope(scope: TempScope): TempScope {
function getVarScope(scope: TempScope): TempScope {
let s = scope;
while (s.type !== "function" && s.type !== "module") {
if (!s.parent) {
Expand Down Expand Up @@ -290,7 +290,7 @@ function createParseJSScopeVisitor(sourceId: SourceId): ParseJSScopeVisitor {
if (path.isFunctionDeclaration() && isNode(tree.id, "Identifier")) {
// This ignores Annex B function declaration hoisting, which
// is probably a fine assumption.
const fnScope = getFunctionScope(parent);
const fnScope = getVarScope(parent);
scope.names[tree.id.name] = {
type: fnScope === scope ? "var" : "let",
declarations: [tree.id.loc],
Expand Down Expand Up @@ -357,7 +357,7 @@ function createParseJSScopeVisitor(sourceId: SourceId): ParseJSScopeVisitor {
!path.parentPath.isXStatement({ left: tree }))
) {
// Finds right lexical environment
const hoistAt = !isLetOrConst(tree) ? getFunctionScope(parent) : parent;
const hoistAt = !isLetOrConst(tree) ? getVarScope(parent) : parent;
tree.declarations.forEach(declarator => {
parseDeclarator(declarator.id, hoistAt, tree.kind);
});
Expand Down

0 comments on commit 36c8222

Please sign in to comment.