Skip to content

Commit

Permalink
Merge pull request #64 from brickadia/fix-global-scope-tracking
Browse files Browse the repository at this point in the history
Fix scope tracking picking the wrong scope when updating current global scope
  • Loading branch information
oscarotero authored May 22, 2024
2 parents 1b293c3 + cb13dd1 commit c5bb240
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Scope = {
// Tracks the scope of the code
// and the variables that should be ignored
class ScopeTracker {
private scopes: Scope[] = [];
private scopes: Scope[] = [{ globalScope: 0, stack: [] }];

// The index of the global/function scope
private globalScope = 0;
Expand Down Expand Up @@ -54,8 +54,8 @@ class ScopeTracker {
}

popScope() {
this.globalScope = this.scopes[this.scopes.length - 1].globalScope;
this.scopes.pop();
this.globalScope = this.scopes[this.scopes.length - 1].globalScope;
}

pushBinding(val: string, global?: boolean) {
Expand Down

0 comments on commit c5bb240

Please sign in to comment.