From f0901a951249f34eb354dbb6a71391afe67d6539 Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 10 Mar 2023 16:56:06 +0100 Subject: [PATCH] Codetools: parse specialization as function result (in function type def) Issue #38970 --- components/codetools/pascalparsertool.pas | 9 +++++-- .../codetools/tests/laztests/bug38970.pas | 26 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 components/codetools/tests/laztests/bug38970.pas diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index a4a7375b75..994f511309 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -4965,8 +4965,13 @@ begin if IsFunction then begin if (CurPos.Flag=cafColon) then begin ReadNextAtom; - AtomIsIdentifierSaveE(20180411194218); - ReadNextAtom; + if UpAtomIs('SPECIALIZE') then begin + ReadSpecialize(true); + end + else begin + AtomIsIdentifierSaveE(20180411194218); + ReadNextAtom; + end; if CurPos.Flag=cafPoint then begin ReadNextAtom; AtomIsIdentifierSaveE(20180411194221); diff --git a/components/codetools/tests/laztests/bug38970.pas b/components/codetools/tests/laztests/bug38970.pas new file mode 100644 index 0000000000..6121013ebd --- /dev/null +++ b/components/codetools/tests/laztests/bug38970.pas @@ -0,0 +1,26 @@ +program bug38970; + +{$mode objfpc}{$H+} +{$modeswitch nestedprocvars} + +uses + {$IFDEF UNIX} + cthreads, + {$ENDIF} + Classes + { you can add units after this }; + +type + generic TOption = record + end; + + generic TIterNestedFunc = function (): specialize TOption{declaration:TOption} is nested; + +procedure Test; +begin +end; + +begin +end. + +