View Issue Details

IDProjectCategoryView StatusLast Update
0030494FPCCompilerpublic2016-08-26 16:23
ReporterMaciej Izak Assigned ToSven Barth  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.1.1 
Fixed in Version3.1.1 
Summary0030494: [patch] for "Compilation raised exception internally" for wrong generic constraint
Descriptionsmall patch from my SmartPointers/ARC internal branch ;). Patch and example attached.

The compiler can't handle in correct way with this code:

{$MODE DELPHI}

type
  TFoo<T: TObject> = record
  end;

var
  foo: TFoo<Integer>; // Error: Compilation raised exception internally
Tagsgenerics
Fixed in Revision34381
FPCOldBugId
FPCTarget
Attached Files

Activities

Maciej Izak

2016-08-21 12:29

reporter  

pexpr.pas.patch (1,008 bytes)   
Index: compiler/pexpr.pas
===================================================================
--- compiler/pexpr.pas	(revision 34356)
+++ compiler/pexpr.pas	(working copy)
@@ -1456,10 +1456,13 @@
                     spezdef:=generate_specialization_phase2(spezcontext,tstoreddef(spezdef),false,'');
                     spezcontext.free;
                     spezcontext:=nil;
-                    srsym:=spezdef.typesym;
-                    srsymtable:=srsym.owner;
-                    check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg);
-                    result:=true;
+                    if spezdef <> generrordef then
+                      begin
+                        srsym:=spezdef.typesym;
+                        srsymtable:=srsym.owner;
+                        check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg);
+                        result:=true;
+                      end;
                   end;
                 else
                   internalerror(2015070302);
pexpr.pas.patch (1,008 bytes)   

Maciej Izak

2016-08-21 12:29

reporter  

test.pp (136 bytes)

Alfred

2016-08-21 16:37

reporter   ~0094239

Would you mind having a look at this expression ?
It also generates: Error: Compilation raised exception internally

Tuple<T> = record
  Item1: T;
  class operator Equal( a, b: Tuple<T> ): Boolean;
  class operator NotEqual( a, b: Tuple<T> ): Boolean;
end;

Maciej Izak

2016-08-21 21:39

reporter   ~0094244

That already works in my non-published (yet) SmartPointers/ARC branch. I will prepare separate patch for this.

Alfred

2016-08-21 22:37

reporter   ~0094245

Ok.
Thanks !

Maciej Izak

2016-08-22 11:54

reporter   ~0094250

@Alfred: I can compile Tuple example without problems on current trunk without my patch. I am working on special case for Implicit/Explicit operators which are a little different.

Alfred

2016-08-22 12:51

reporter   ~0094253

Please excuse me, my example was not complete !

program project1;

type
  Tuple<T> = record
    Item1: T;
    class operator Equal( a, b: Tuple<T> ): Boolean;
    class operator NotEqual( a, b: Tuple<T> ): Boolean;
  end;

  Tuple = record
    class function Create<T>( Item1: T ): Tuple<T>; overload; static;
  end;

class function Tuple.Create<T>( Item1: T ): Tuple<T>;
begin
  Result.Item1 := Item1;
end;

class operator Tuple<T>.Equal( a, b: Tuple<T> ): Boolean;
begin
  Result := TEqualityComparer<T>.Default.Equals( a.Item1, b.Item1 );
end;

class operator Tuple<T>.NotEqual( a, b: Tuple<T> ): Boolean;
begin
  Result := not( a = b );
end;

begin
end.

Maciej Izak

2016-08-22 15:15

reporter   ~0094260

Presented bug is different story... Please create new bug report for this.

Sven Barth

2016-08-26 16:23

manager   ~0094324

Thanks for the patch. Please test and close if okay.

Issue History

Date Modified Username Field Change
2016-08-21 12:29 Maciej Izak New Issue
2016-08-21 12:29 Maciej Izak File Added: pexpr.pas.patch
2016-08-21 12:29 Maciej Izak File Added: test.pp
2016-08-21 16:37 Alfred Note Added: 0094239
2016-08-21 21:39 Maciej Izak Note Added: 0094244
2016-08-21 22:37 Alfred Note Added: 0094245
2016-08-22 11:36 Cyrax Tag Attached: generics
2016-08-22 11:54 Maciej Izak Note Added: 0094250
2016-08-22 12:51 Alfred Note Added: 0094253
2016-08-22 15:15 Maciej Izak Note Added: 0094260
2016-08-26 16:06 Sven Barth Assigned To => Sven Barth
2016-08-26 16:06 Sven Barth Status new => assigned
2016-08-26 16:23 Sven Barth Fixed in Revision => 34381
2016-08-26 16:23 Sven Barth Note Added: 0094324
2016-08-26 16:23 Sven Barth Status assigned => resolved
2016-08-26 16:23 Sven Barth Fixed in Version => 3.1.1
2016-08-26 16:23 Sven Barth Resolution open => fixed