Simplify creating Var

This commit is contained in:
Joscha 2022-11-22 17:14:52 +01:00
parent 6f7683ad1e
commit 40c28d9496
4 changed files with 55 additions and 34 deletions

View file

@ -37,17 +37,8 @@ impl FuncDef {
body,
span,
} => {
// `function s0 ( s1 arg s2 ) s3 body`
// -> `function ( ) '{ local arg = 'arg(), body }`
let arg_call = Call::no_arg(Lit::Builtin(Builtin::Arg, span).expr().boxed(), span);
let arg_assign = Var::AssignIdent {
local: Some(Space::empty(span)),
name: arg,
s0: Space::empty(span),
s1: Space::empty(span),
value: arg_call.expr().boxed(),
span,
};
let arg_assign = Var::assign_ident(true, arg, arg_call.expr().boxed(), span);
let body = BoundedSeparated::new(span)
.then(TableLitElem::Positional(arg_assign.expr().boxed()))
.then(TableLitElem::Positional(body))