Seriously, f**k Delphi and generics - already found the first compiler regression -.-

Seriously, f**k Delphi and generics - already found the first compiler regression -.-

This does not compile in XE4 (win32/win64) anymore:

type
  IGrouping = interface
  end;

  Enumerable = record
    function GroupBy: Enumerable>;
  end;

function Enumerable.GroupBy: Enumerable>;
begin
end;

E2604: Recursive use of generic type

P.S.: And f**k QC that always gives me timeouts when searching for existing reports.

Comments

  1. wtf?! o.O that seems perfectly legitimate..., did you add any method on IGrouping? maybe there's a special case..

    ReplyDelete
  2. Dorin Duminica This is just the minimal testcase that does not compile, real code is far more complex. The error occurs on the GroupBy method declaration. Seems the compiler is going to build Enumerable> which has itself a GroupBy method... and so on -> recursion. 2010 to XE3 works (Spring4D refactoring branch includes a testcase for GroupBy)

    ReplyDelete
  3. well, dreams start to fall apart already ):

    ReplyDelete
  4. Stefan Glienke Breakage. It seems to be a rapidly spreading disease. I have headaches enough with XE, TMS, et al. I assume the test case is there because Spring4D actually uses GroupBy?

    ReplyDelete
  5. There is a bug that came up from Spring4D that is already fixed internally. Sorry don't have the QC at hand. This seems very close, not sure if the same.

    ReplyDelete
  6. I am having a problem wrapping my head around

    Enumerable = record
        function GroupBy: Enumerable>;
      end;

    was that possible in XE3?  Looks circular to me.

    ReplyDelete
  7. Well... Whenever you want to play some tricks in Delphi with excitement, you may have to face that stupid compiler at the end...

    ReplyDelete
  8. Bill Meyer Yes, I have implemented almost every extension method from .Net IEnumerable along with doing some refactorings on the collection types in Spring4D.
    Marco Cantù I don't remember any other open bug related to compiler/generics from Spring4D, so please post if you remember.
    Lars Fosdal Yes, it was possible - even in 2010 (actually to my surprise)

    It's no wonder Alex gave up with DeHL and his collection library...

    ReplyDelete
  9. Recursion is, see the definition of Recursion.

    ReplyDelete
  10. Lars Fosdal How is it different from 
      TMyRec = record
        function Foo: TMyRec;
      end; 

    which also compiles just fine? My hunch is that the restriction that fields must come before methods/properties is what saves the day. When the compiler sees a method/property, it knows the memory-layout of the type, and as such the type is complete enough.

    ReplyDelete
  11. The dynamic type argument makes it different. When does the recursion end?

    ReplyDelete
  12. Lars Fosdal Not sure it is. It returns an Enumeration>, and IGrouping is as well defined as needed, isn't it? I mean, it's an interface, and since you can't do specialization with generics there's not much more you need to know for a function declaration.

    ReplyDelete
  13. In your sourcecode, I see a {$IF CompilerVersion < 24}, which seems to indicate it also fails in Delphi XE3. Is that correct?

    ReplyDelete
  14. Found your QC: http://qc.embarcadero.com/wc/qcmain.aspx?d=116151 IT does not indicate in which Delphi versions it DOES work. Can you please indicate that?
    Someone did re-open the issue BTW (:

    ReplyDelete
  15. I checked: it works at least in Delphi XE2 and it indeeds is not an infinite recursion. So I added a comment with source code showing that.
    http://qc.embarcadero.com/wc/qcmain.aspx?d=116151

    ReplyDelete
  16. It was reopened automatically because I commented but I have no clue if anyone noticed it and/or it was moved to their internal tracker.

    ReplyDelete
  17. Lars Fosdal I know. Some XE4 compiler issues were fixed in XE5, but this wasn't. I'm trying to bump up the prio on this one given that it breaks parts of the link support in DSharp.

    ReplyDelete
  18. Closed as designed. LOL WTG EMBT. Just close regressions as designed because you don't fu**ing care how to fix things properly. I guess that is if you replace people that know wtf they are doing (like Barry) with interns.

    ReplyDelete
  19. Stefan Glienke It's like they don't want us to keeping buying Delphi...

    ReplyDelete
  20. Stefan Glienke - Is there a way to get around this for your needs?

    ReplyDelete
  21. Lars Fosdal Yes, exclude this for XE4 and higher.

    While I did the collections refactorings in Spring4d I implemented almost all IEnumerable extension methods using the Enumerable record trick I blogged about (http://delphisorcery.blogspot.de/2013/04/why-no-extension-methods-in-delphi.html) just to experience the compiletimes to explode - and with explode I mean instead of 8 seconds for the packages it took a couple of minutes). After applying a compiler fix (from you know who) it went down to a couple of seconds again. I then decided to not include these changes into the package because I don't want people to be forced to use an inofficial compiler fix to be able to work with a feature they might not need.

    ReplyDelete
  22. Stefan Glienke Propagation of feature removal. :-(  Some stuff can't help flowing downhill.

    ReplyDelete

Post a Comment