View Issue Details

IDProjectCategoryView StatusLast Update
0038111pas2jstranspilerpublic2020-11-21 22:44
ReporterSven Barth Assigned ToMattias Gaertner  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
Product Versiontrunk 
Summary0038111: Access violation instead of compiler error for faulty code
DescriptionWhen assigning an anonymous function with an incorrect signature to an anonymous function parameter there is at least one situation where an access violation is triggered instead of a compile error.
Steps To ReproduceCompile attached unit.
TagsNo tags attached.
Fixed in Revision
Attached Files

Activities

Sven Barth

2020-11-21 22:31

developer  

tanonfunc.pp (697 bytes)   
unit tanonfunc;

{$mode objfpc}

interface

uses
  Generics.Collections;

type
  TBuilderEntry = record
    Name: String;
  end;

  TBuildHistoryEntry = record
  end;

procedure SortByDate(aAscending: Boolean);

implementation

uses
  Generics.Defaults;

procedure SortByDate(aAscending: Boolean);
begin
  specialize TComparer<TBuilderHistoryEntry>.Construct(function(const aLeft, aRight: TBuilderEntry): Integer
    begin
      if aLeft.Name > aRight.Name then
        Result := 1
      else if aLeft.Name < aRight.Name then
        Result := -1
      else
        Result := 0;

      if aAscending then
        Result := - Result;
    end);
end;

end.

tanonfunc.pp (697 bytes)   

Issue History

Date Modified Username Field Change
2020-11-21 22:31 Sven Barth New Issue
2020-11-21 22:31 Sven Barth File Added: tanonfunc.pp
2020-11-21 22:44 Mattias Gaertner Assigned To => Mattias Gaertner
2020-11-21 22:44 Mattias Gaertner Status new => assigned