Skip to content

Commit

Permalink
fix: resolve variables in function statements (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
prevwong authored Oct 30, 2023
1 parent 16d6902 commit 5d934d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/rich-crabs-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rekajs/core': patch
---

Fix resolve variables inside function statements
6 changes: 5 additions & 1 deletion packages/core/src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ export class Resolver {
this.resolveExpr(expr.consequent, scope);
this.resolveExpr(expr.alternate, scope);
}

if (expr instanceof t.Val) {
this.resolveVariable(expr, scope);
}
}

private resolveComponent(component: t.Component, scope: Scope) {
Expand Down Expand Up @@ -339,7 +343,7 @@ export class Resolver {
this.bindNodeToScope(program, this.scope);

program.globals.forEach((global) => {
this.resolveVariable(global, this.scope);
this.resolveExpr(global, this.scope);
});

program.components.forEach((component) => {
Expand Down

1 comment on commit 5d934d0

@vercel
Copy link

@vercel vercel bot commented on 5d934d0 Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

reka – ./

reka-prevwong.vercel.app
reka.js.org
rekajs.vercel.app
reka-git-main-prevwong.vercel.app

Please sign in to comment.