View Issue Details

IDProjectCategoryView StatusLast Update
0037624pas2jsrtlpublic2020-09-21 13:05
ReporterHighball Assigned ToMattias Gaertner  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Summary0037624: uncaught A/V with generic method and constraint
Descriptionwhen creating a class with a generic method as well as a constraint the following exception occurs when attempting to compile
Fatal: bug: uncaught EAccessViolation: Access violation

without the constraint, the compilation works as expected
Steps To Reproduceexample method attached in zip project
Additional Informationa method like this --> function IsType<T : IInterface> : Boolean;
TagsNo tags attached.
Fixed in Revision46902.
Attached Files

Activities

Highball

2020-08-22 23:52

reporter  

generic-constraint.zip (5,070 bytes)

Highball

2020-08-23 00:03

reporter   ~0125086

I don't know if this is the same issue, but testing further, the same exception occurs *without* the constraint, but when returning an interface as the function result

this method does not compile
function IsType<T> : IInterface;

this method will
function IsType<T> : Boolean;

henrique

2020-08-26 16:23

reporter   ~0125136

It's happen to me too!

Highball

2020-08-29 23:26

reporter   ~0125209

just noticed I categorized this bug incorrectly, it should be "compiler" not "rtl" (but I don't know how to adjust... and not sure it's that big of a deal)

henrique

2020-09-02 19:33

reporter   ~0125300

I've attach a fix for this problem. But it creates a new problem in checking interface types, if you pass a parameter class, everything works.
Access violation.patch (1,570 bytes)   
From c13c1a1024754213381ff3e349368540928e9b79 Mon Sep 17 00:00:00 2001
From: Henrique Gottardi Werlang <henriquewerlang@hotmail.com>
Date: Wed, 2 Sep 2020 14:09:38 -0300
Subject: [PATCH] Access violation in generic interface.

---
 packages/fcl-passrc/src/pasresolver.pp | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/packages/fcl-passrc/src/pasresolver.pp b/packages/fcl-passrc/src/pasresolver.pp
index d1b41b0bef..e318f78e87 100644
--- a/packages/fcl-passrc/src/pasresolver.pp
+++ b/packages/fcl-passrc/src/pasresolver.pp
@@ -6628,11 +6628,14 @@ begin
             end;
           okInterface:
             begin
-            // there can be multiple interfacetype constraint
-            if not (LastType is TPasClassType) then
-              RaiseCannotBeTogether(20190720211236,LastType.Name,MemberType.Name);
-            if TPasClassType(LastType).ObjKind<>okInterface then
-              RaiseCannotBeTogether(20190720211304,LastType.Name,MemberType.Name);
+            if Assigned(LastType) then
+              begin
+              // there can be multiple interfacetype constraint
+              if not (LastType is TPasClassType) then
+                RaiseCannotBeTogether(20190720211236,LastType.Name,MemberType.Name);
+              if TPasClassType(LastType).ObjKind<>okInterface then
+                RaiseCannotBeTogether(20190720211304,LastType.Name,MemberType.Name);
+              end;
             end
           else
             RaiseXIsNotAValidConstraint(20190720210919,MemberType.Name);
-- 
2.28.0.windows.1

Access violation.patch (1,570 bytes)   

henrique

2020-09-09 13:28

reporter   ~0125448

Someone can check this implementation of me?

Highball

2020-09-13 18:44

reporter   ~0125527

Any update on reviewing the proposed fix? Would be handy to be able to do this since I pretty much exclusively use interfaces and it would simplify my web framework I'm building

Mattias Gaertner

2020-09-20 01:42

developer   ~0125648

Thanks for the patch.

Highball

2020-09-20 03:17

reporter   ~0125649

Thanks guys

Issue History

Date Modified Username Field Change
2020-08-22 23:52 Highball New Issue
2020-08-22 23:52 Highball File Added: generic-constraint.zip
2020-08-23 00:03 Highball Note Added: 0125086
2020-08-26 16:23 henrique Note Added: 0125136
2020-08-29 23:26 Highball Note Added: 0125209
2020-09-02 19:33 henrique Note Added: 0125300
2020-09-02 19:33 henrique File Added: Access violation.patch
2020-09-09 13:28 henrique Note Added: 0125448
2020-09-13 18:44 Highball Note Added: 0125527
2020-09-16 23:50 Michael Van Canneyt Assigned To => Mattias Gaertner
2020-09-16 23:50 Michael Van Canneyt Status new => assigned
2020-09-20 01:42 Mattias Gaertner Status assigned => resolved
2020-09-20 01:42 Mattias Gaertner Resolution open => fixed
2020-09-20 01:42 Mattias Gaertner Fixed in Revision => 46902.
2020-09-20 01:42 Mattias Gaertner Note Added: 0125648
2020-09-20 03:17 Highball Note Added: 0125649