From 7ad24d803e82a8e5dcf35437106de4bebfa7029d Mon Sep 17 00:00:00 2001 From: ImVeryBad Date: Sun, 18 Jan 2026 17:12:23 +0100 Subject: [PATCH] Add optional and default argument values parsing for lambdas. --- hscript/Parser.hx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hscript/Parser.hx b/hscript/Parser.hx index 6c2fb53a..015c4b1b 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -554,9 +554,17 @@ class Parser { while (true) { - var id = getIdent(); - var t = maybe(TDoubleDot) ? parseType() : null; - args.push({name: id, t: t}); + var arg:Argument = {name: null}; + if (maybe(TQuestion)) arg.opt = true; + arg.name = getIdent(); + + if (allowTypes) + { + if (maybe(TDoubleDot)) arg.t = parseType(); + if (maybe(TOp("="))) arg.value = parseExpr(); + } + args.push(arg); + var tk = token(); switch (tk) {