Browse Source

fcl-passrc: fixed function type inside function

git-svn-id: trunk@35863 -
Mattias Gaertner 8 years ago
parent
commit
8da6a9fc84
2 changed files with 18 additions and 0 deletions
  1. 1 0
      packages/fcl-passrc/src/pasresolver.pp
  2. 17 0
      packages/fcl-passrc/tests/tcresolver.pas

+ 1 - 0
packages/fcl-passrc/src/pasresolver.pp

@@ -5923,6 +5923,7 @@ end;
 procedure TPasResolver.AddFunctionResult(El: TPasResultElement);
 procedure TPasResolver.AddFunctionResult(El: TPasResultElement);
 begin
 begin
   if TopScope.ClassType<>TPasProcedureScope then exit;
   if TopScope.ClassType<>TPasProcedureScope then exit;
+  if not (El.Parent is TPasProcedure) then exit;
   AddIdentifier(TPasProcedureScope(TopScope),ResolverResultVar,El,pikSimple);
   AddIdentifier(TPasProcedureScope(TopScope),ResolverResultVar,El,pikSimple);
 end;
 end;
 
 

+ 17 - 0
packages/fcl-passrc/tests/tcresolver.pas

@@ -542,6 +542,7 @@ type
     Procedure TestProcType_Property;
     Procedure TestProcType_Property;
     Procedure TestProcType_PropertyCallWrongArgFail;
     Procedure TestProcType_PropertyCallWrongArgFail;
     Procedure TestProcType_Typecast;
     Procedure TestProcType_Typecast;
+    Procedure TestProcType_InsideFunction;
 
 
     // pointer
     // pointer
     Procedure TestPointer;
     Procedure TestPointer;
@@ -8894,6 +8895,22 @@ begin
   ParseProgram;
   ParseProgram;
 end;
 end;
 
 
+procedure TTestResolver.TestProcType_InsideFunction;
+begin
+  StartProgram(false);
+  Add([
+  'function GetIt: longint;',
+  'type TGetter = function: longint;',
+  'var',
+  '  p: Pointer;',
+  'begin',
+  '  Result:=TGetter(p)();',
+  'end;',
+  'begin',
+  '']);
+  ParseProgram;
+end;
+
 procedure TTestResolver.TestPointer;
 procedure TTestResolver.TestPointer;
 begin
 begin
   StartProgram(false);
   StartProgram(false);