Hi Michael, Yes, TSub.Count should be used. I agree that it is dirty and confusing. Best would be to only have it work in Delphi mode.
Kind regards, Birger -----Oorspronkelijk bericht----- Van: Michael Van Canneyt <mich...@freepascal.org> Verzonden: wo 20-10-2010 13:22 Aan: FPC developers' list <fpc-devel@lists.freepascal.org>; Onderwerp: Re: [fpc-devel] Fatal: Internal error 200111022 > > Hello, > > Which 'Count' should the compiler select ? I suspect TSub.Count ? > > I think we should prohibit this dubious construct in ObjFC mode. > (but try to be delphi compatible in Delphi mode) > > Michael. > > On Wed, 20 Oct 2010, Birger Jansen wrote: > > > I'm not sure if this is the correct way to report this, please correct me > > if > I should report in another way. > > > > I found an old conversation between Leonardo and Florian about the Fatail > internal error 200111022. The thread concluded that they could not reproduce > the error. > > > > I got this error while converting a large project from Delphi to FPC. It > turns out that a base class has a property Count, and a derived class has a > function with the same name Count. This will compile, untill you call the > property or function Count. > > > > I created an example that should explain it. Uncomment the marked line to > > get > the fatal internal error: > > > > program project1; > > > > {$mode objfpc}{$H+} > > > > uses > > {$IFDEF UNIX}{$IFDEF UseCThreads} > > cthreads, > > {$ENDIF}{$ENDIF} > > Classes; > > > > type > > > > TBase = class > > private > > function GetCount: Integer; > > public > > property Count: Integer read GetCount; > > end; > > > > TSub = class(TBase) > > public > > function Count: Integer; overload; > > end; > > > > function TSub.Count: Integer; > > begin > > Result := 0; > > end; > > > > { TBase } > > > > function TBase.GetCount: Integer; > > begin > > Result := 0; > > end; > > > > var > > MySub: TSub; > > i : Integer; > > begin > > MySub := TSub.Create; > > // uncomment the next line for Fatal Internal error 200111022: > > // for i := 0 to MySub.Count do begin end; > > end. > > _______________________________________________ > > fpc-devel maillist - fpc-devel@lists.freepascal.org > > http://lists.freepascal.org/mailman/listinfo/fpc-devel > > > _______________________________________________ > fpc-devel maillist - fpc-devel@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-devel > _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel