From b28384fed1ce638e8b00b72dba974e9fd7e55eb4 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Wed, 28 Oct 2026 13:36:16 +0000 Subject: feat(overload): support default return types Co-Authored-By: Claude Opus 5.5 --- lib/Parser/ParserFunction.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/Parser/ParserFunction.cc') diff --git a/lib/Parser/ParserFunction.cc b/lib/Parser/ParserFunction.cc index 8f3a117..2f80c42 100644 --- a/lib/Parser/ParserFunction.cc +++ b/lib/Parser/ParserFunction.cc @@ -203,8 +203,13 @@ std::unique_ptr Parser::ParseFunction(const std::string &OwnerCl if (!Args) return nullptr; std::string RetType = "INTEGER"; + bool IsDefaultReturn = false; if (CurTok == tok_returns) { getNextToken(); + if (CurTok == tok_default) { + IsDefaultReturn = true; + getNextToken(); + } if (CurTok == tok_array) { cps::sourceError(Lex.getLine(), "A FUNCTION cannot RETURN an array; use a BYREF PROCEDURE parameter instead"); return nullptr; @@ -218,8 +223,14 @@ std::unique_ptr Parser::ParseFunction(const std::string &OwnerCl auto Proto = std::make_unique(Name, std::move(*Args), RetType, false, OwnerClass, IsPublic, IsOverload); Proto->setOperator(Operator); + Proto->setDefaultReturn(IsDefaultReturn); - return ParseFunctionBody(std::move(Proto), tok_endfunction, "expected ENDFUNCTION", Line); + auto Def = ParseFunctionBody(std::move(Proto), tok_endfunction, "expected ENDFUNCTION", Line); + if (IsDefaultReturn && !CurrentTemplate.empty()) { + sourceError(Line, "DEFAULT return types are not supported in templates"); + return nullptr; + } + return Def; } std::unique_ptr Parser::ParseProcedure(const std::string &OwnerClass, bool IsPublic, bool IsOverload) { -- cgit v1.3.1-4-g156e