Skip to content

Commit

Permalink
Static eval for arrow functions
Browse files Browse the repository at this point in the history
  • Loading branch information
voltrevo committed Jul 24, 2023
1 parent d3383ff commit 72a7ab5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions inputs/passing/exportDefaultArrow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! test_output("Hi")

export default () => {
return "Hi";
};
8 changes: 7 additions & 1 deletion valuescript_compiler/src/module_compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,8 +1046,14 @@ impl ModuleCompiler {
Value::String("(error)".to_string())
}
},
swc_ecma_ast::Expr::Arrow(arrow) => {
let p = self.allocate_defn_numbered("_anon");
let mut fn_defns = self.compile_fn(p.clone(), None, Functionish::Arrow(arrow.clone()));
self.module.definitions.append(&mut fn_defns);

Value::Pointer(p)
}
swc_ecma_ast::Expr::TaggedTpl(_)
| swc_ecma_ast::Expr::Arrow(_)
| swc_ecma_ast::Expr::Class(_)
| swc_ecma_ast::Expr::Yield(_)
| swc_ecma_ast::Expr::MetaProp(_)
Expand Down

0 comments on commit 72a7ab5

Please sign in to comment.