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.
This does not compile in XE4 (win32/win64) anymore:
type
IGrouping
end;
Enumerable
function GroupBy: Enumerable
end;
function 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.
wtf?! o.O that seems perfectly legitimate..., did you add any method on IGrouping? maybe there's a special case..
ReplyDeleteDorin 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)
ReplyDeletewell, dreams start to fall apart already ):
ReplyDeleteStefan 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?
ReplyDeleteThere 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.
ReplyDeleteI am having a problem wrapping my head around
ReplyDeleteEnumerable = record
function GroupBy: Enumerable>;
end;
was that possible in XE3? Looks circular to me.
Well... Whenever you want to play some tricks in Delphi with excitement, you may have to face that stupid compiler at the end...
ReplyDeleteBill Meyer Yes, I have implemented almost every extension method from .Net IEnumerable along with doing some refactorings on the collection types in Spring4D.
ReplyDeleteMarco 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...
Recursion is, see the definition of Recursion.
ReplyDeleteLars Fosdal How is it different from
ReplyDeleteTMyRec = 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.
The dynamic type argument makes it different. When does the recursion end?
ReplyDeleteLars 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.
ReplyDeleteIn your sourcecode, I see a {$IF CompilerVersion < 24}, which seems to indicate it also fails in Delphi XE3. Is that correct?
ReplyDeleteFound 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?
ReplyDeleteSomeone did re-open the issue BTW (:
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.
ReplyDeletehttp://qc.embarcadero.com/wc/qcmain.aspx?d=116151
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.
ReplyDeleteThe issue still exists in XE5.
ReplyDeleteLars 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.
ReplyDeleteClosed 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.
ReplyDeleteStefan Glienke It's like they don't want us to keeping buying Delphi...
ReplyDeleteStefan Glienke - Is there a way to get around this for your needs?
ReplyDeleteLars Fosdal Yes, exclude this for XE4 and higher.
ReplyDeleteWhile 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.
Stefan Glienke - Ok, thanks.
ReplyDeleteStefan Glienke Propagation of feature removal. :-( Some stuff can't help flowing downhill.
ReplyDelete