[fpc-pascal] Bug in FPC 3.0.0 (was: Bug in FPC 3.0.0?)
Michael Van Canneyt
michael at freepascal.org
Tue Feb 23 11:30:54 CET 2016
On Tue, 23 Feb 2016, Serguei TARASSOV wrote:
> Hello,
>
> Sorry, my previous example was not complete.
> Here is a problem detected when compiling UniDAC 6.2.8.
> Taken from real code in VirtualTable.pas
>
> program Project1;
>
> {$MODE DELPHI}
>
> uses
> SysUtils, Classes, DB;
>
> procedure InternalCreateFieldDefs(Fields: TFields; FieldDefs: TFieldDefs);
> var
> F: TField;
> FieldDef: TFieldDef;
> begin
> begin
> with F do
> begin
> FieldDef := FieldDefs.AddFieldDef;
> // in FPC 3.0.0 Error: No member is provided to access property
> // in FPC 2.6.4 compiles OK
The problem is in your code and the use of WITH, as I surmised in my
previous mail.
In 2.6.4, FieldDef is resolved to the LOCAL VARIABLE FieldDef.
The code compiles ok.
In 3.0.0, FieldDef is a NEW READ-ONLY property in TField.
Because of the WITH, the compiler resolves FieldDef to this property, but it
is read-only, an so it gives an error.
Change your code to
Var
AFieldDef: TFieldDef;
and
AFieldDef := FieldDefs.AddFieldDef;
and all will be well.
Michael.
More information about the fpc-pascal
mailing list