View Issue Details

IDProjectCategoryView StatusLast Update
0036179FPCFCLpublic2019-10-21 12:51
ReporterRyan JosephAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.3.1Product Build 
Target VersionFixed in Version3.3.1 
Summary0036179: fcl-passrc record sections in nested functions fail to parse
DescriptionSections in records which are nested inside functions produce errors.

{$mode objfpc}
{$modeswitch advancedrecords}

program bugs;

procedure DoThis;
  type
    TMyRecord = record
      // ERROR HERE
      private
        x, y, z: integer;
    end;
  begin
  end;

begin
end.
Steps To ReproduceUse test.pas to parse the bug file.
TagsNo tags attached.
Fixed in Revision43228
FPCOldBugId
FPCTarget3.2.0
Attached Files
  • bug_1.pas (185 bytes)
    {$mode objfpc}
    {$modeswitch advancedrecords}
    
    program bugs;
    
    procedure DoThis;
      type
        TMyRecord = record
          private
            x, y, z: integer; 
        end;
      begin
      end;
    
    begin
    end.
    bug_1.pas (185 bytes)
  • test.pas (1,041 bytes)
    {$mode objfpc}
    {$H+}
    
    program test;
    uses
      PasTree, PParser;
    
    type
      TSimpleEngine = class(TPasTreeContainer)
      public
        function CreateElement(AClass: TPTreeElement; const AName: String; AParent: TPasElement; AVisibility: TPasMemberVisibility; const ASourceFilename: String; ASourceLinenumber: Integer): TPasElement; override;
        function FindElement(const AName: String): TPasElement; override;
       end;
    
    function TSimpleEngine.FindElement(const AName: String): TPasElement;
    begin
      result := nil;
    end;
    
    function TSimpleEngine.CreateElement(AClass: TPTreeElement; const AName: String; AParent: TPasElement; AVisibility: TPasMemberVisibility; const ASourceFilename: String; ASourceLinenumber: Integer): TPasElement;
    begin
      result := AClass.Create(AName, AParent);
      result.Visibility := AVisibility;
      result.SourceFilename := ASourceFilename;
      result.SourceLinenumber := ASourceLinenumber;
    end;
    
    var
      engine: TSimpleEngine;
    begin
      engine := TSimpleEngine.Create;
      ParseSource(engine, '-Mobjfpc bug_1.pas', 'darwin', 'x86_64'); 
    end.
    test.pas (1,041 bytes)

Activities

Ryan Joseph

2019-10-14 16:29

reporter  

bug_1.pas (185 bytes)
{$mode objfpc}
{$modeswitch advancedrecords}

program bugs;

procedure DoThis;
  type
    TMyRecord = record
      private
        x, y, z: integer; 
    end;
  begin
  end;

begin
end.
bug_1.pas (185 bytes)
test.pas (1,041 bytes)
{$mode objfpc}
{$H+}

program test;
uses
  PasTree, PParser;

type
  TSimpleEngine = class(TPasTreeContainer)
  public
    function CreateElement(AClass: TPTreeElement; const AName: String; AParent: TPasElement; AVisibility: TPasMemberVisibility; const ASourceFilename: String; ASourceLinenumber: Integer): TPasElement; override;
    function FindElement(const AName: String): TPasElement; override;
   end;

function TSimpleEngine.FindElement(const AName: String): TPasElement;
begin
  result := nil;
end;

function TSimpleEngine.CreateElement(AClass: TPTreeElement; const AName: String; AParent: TPasElement; AVisibility: TPasMemberVisibility; const ASourceFilename: String; ASourceLinenumber: Integer): TPasElement;
begin
  result := AClass.Create(AName, AParent);
  result.Visibility := AVisibility;
  result.SourceFilename := ASourceFilename;
  result.SourceLinenumber := ASourceLinenumber;
end;

var
  engine: TSimpleEngine;
begin
  engine := TSimpleEngine.Create;
  ParseSource(engine, '-Mobjfpc bug_1.pas', 'darwin', 'x86_64'); 
end.
test.pas (1,041 bytes)

Michael Van Canneyt

2019-10-19 15:37

administrator   ~0118695

Fixed. Collateral damage from not allowing advanced records inside anonymous functions. Please test and close if OK.

Mattias Gaertner

2019-10-21 12:51

manager   ~0118752

Delphi 10.3.2 allows "private" in local records, even inside anonymous functions. I fixed it.

Issue History

Date Modified Username Field Change
2019-10-14 16:29 Ryan Joseph New Issue
2019-10-14 16:29 Ryan Joseph File Added: bug_1.pas
2019-10-14 16:29 Ryan Joseph File Added: test.pas
2019-10-19 15:37 Michael Van Canneyt Assigned To => Michael Van Canneyt
2019-10-19 15:37 Michael Van Canneyt Status new => resolved
2019-10-19 15:37 Michael Van Canneyt Resolution open => fixed
2019-10-19 15:37 Michael Van Canneyt Fixed in Version => 3.3.1
2019-10-19 15:37 Michael Van Canneyt Fixed in Revision => 43228
2019-10-19 15:37 Michael Van Canneyt FPCTarget => 3.2.0
2019-10-19 15:37 Michael Van Canneyt Note Added: 0118695
2019-10-21 12:51 Mattias Gaertner Note Added: 0118752