diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-30 14:23:32 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-30 14:23:32 +0000 |
| commit | 4cb0d9b196008bc55dbfcdac1f9211dbbc879895 (patch) | |
| tree | 0d95a2682ef26455483c4bb9222e1dff0d5c8e69 /lib/Parser/Parser.cc | |
| parent | 63109537383fa58c6a1db95f275d6b5de63b0015 (diff) | |
feat(types): support implicit single-argument constructors
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/Parser/Parser.cc')
| -rw-r--r-- | lib/Parser/Parser.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Parser/Parser.cc b/lib/Parser/Parser.cc index ad2e408..227e309 100644 --- a/lib/Parser/Parser.cc +++ b/lib/Parser/Parser.cc @@ -50,7 +50,7 @@ void Parser::syncToStatementStart() { case tok_delete: case tok_constant: case tok_declare: case tok_identifier: case tok_operator: case tok_input: case tok_output: case tok_case: case tok_endcase: case tok_otherwise: case tok_if: case tok_while: case tok_repeat: case tok_for: - case tok_template: case tok_overload: case tok_function: case tok_procedure: case tok_call: case tok_return: + case tok_template: case tok_implicit: case tok_overload: case tok_function: case tok_procedure: case tok_call: case tok_return: case tok_else: case tok_endif: case tok_endwhile: case tok_until: case tok_next: case tok_endfunction: case tok_endprocedure: case tok_openfile: case tok_readfile: case tok_writefile: case tok_closefile: @@ -157,9 +157,16 @@ std::unique_ptr<StmtAST> Parser::ParseStatementImpl() { else if (CurTok == tok_for) { return ParseForStmt(); } - else if (CurTok == tok_overload) { + else if (CurTok == tok_implicit || CurTok == tok_overload) { int Line = Lex.getLine(); + bool Overload = CurTok == tok_overload; getNextToken(); + bool Implicit = !Overload || CurTok == tok_implicit; + if (Overload && Implicit) getNextToken(); + if (Implicit) { + cps::sourceError(Line, "IMPLICIT is only allowed on a CLASS constructor NEW"); + return nullptr; + } if (CurTok == tok_function) return ParseFunction({}, true, true); if (CurTok == tok_procedure) return ParseProcedure({}, true, true); cps::sourceError(Line, "OVERLOAD must be followed by FUNCTION or PROCEDURE"); |
