diff --git a/moonscript/parse.lua b/moonscript/parse.lua index f3fda48..da6731e 100644 --- a/moonscript/parse.lua +++ b/moonscript/parse.lua @@ -188,7 +188,7 @@ local build_grammar = wrap_env(debug_grammar, function(root) KeyValueList = KeyValue * (sym(",") * KeyValue) ^ 0, KeyValueLine = CheckIndent * KeyValueList * sym(",") ^ -1, FnArgsDef = sym("(") * White * Ct(FnArgDefList ^ -1) * (key("using") * Ct(NameList + Space * "nil") + Ct("")) * White * sym(")") + Ct("") * Ct(""), - FnArgDefList = FnArgDef * (sym(",") * White * FnArgDef) ^ 0 * (sym(",") * White * Ct(VarArg)) ^ 0 + Ct(VarArg), + FnArgDefList = FnArgDef * ((sym(",") + Break) * White * FnArgDef) ^ 0 * ((sym(",") + Break) * White * Ct(VarArg)) ^ 0 + Ct(VarArg), FnArgDef = Ct((Name + SelfName) * (sym("=") * Exp) ^ -1), FunLit = FnArgsDef * (sym("->") * Cc("slim") + sym("=>") * Cc("fat")) * (Body + Ct("")) / mark("fndef"), NameList = Name * (sym(",") * Name) ^ 0, diff --git a/moonscript/parse.moon b/moonscript/parse.moon index d1a5fff..7fd5de6 100644 --- a/moonscript/parse.moon +++ b/moonscript/parse.moon @@ -296,7 +296,7 @@ build_grammar = wrap_env debug_grammar, (root) -> (key"using" * Ct(NameList + Space * "nil") + Ct"") * White * sym")" + Ct"" * Ct"" - FnArgDefList: FnArgDef * (sym"," * White * FnArgDef)^0 * (sym"," * White * Ct(VarArg))^0 + Ct(VarArg) + FnArgDefList: FnArgDef * ((sym"," + Break) * White * FnArgDef)^0 * ((sym"," + Break) * White * Ct(VarArg))^0 + Ct(VarArg) FnArgDef: Ct((Name + SelfName) * (sym"=" * Exp)^-1) FunLit: FnArgsDef * diff --git a/spec/inputs/funcs.moon b/spec/inputs/funcs.moon index 37387f8..08a29b6 100644 --- a/spec/inputs/funcs.moon +++ b/spec/inputs/funcs.moon @@ -129,6 +129,28 @@ y = (a="hi", ) -> print "what" +-- + +args = (a + b) -> + print "what" + + +args = (a="hi" + b=23) -> + print "what" + +args = ( + a="hi" + b=23) -> + print "what" + + +args = (f,g,m + a="hi" + b=23 +) -> + print "what" diff --git a/spec/outputs/funcs.lua b/spec/outputs/funcs.lua index 43cb934..f5e2cf3 100644 --- a/spec/outputs/funcs.lua +++ b/spec/outputs/funcs.lua @@ -176,4 +176,35 @@ y = function(a, b, ...) end return print("what") end +local args +args = function(a, b) + return print("what") +end +args = function(a, b) + if a == nil then + a = "hi" + end + if b == nil then + b = 23 + end + return print("what") +end +args = function(a, b) + if a == nil then + a = "hi" + end + if b == nil then + b = 23 + end + return print("what") +end +args = function(f, g, m, a, b) + if a == nil then + a = "hi" + end + if b == nil then + b = 23 + end + return print("what") +end return nil \ No newline at end of file