[fpc-devel] FPC compiles malformed code
    Graeme Geldenhuys 
    graemeg.lists at gmail.com
       
    Thu Aug 24 09:44:33 CEST 2006
    
    
  
Hi,
Shouldn't FPC complain about the code below - I marked the lines with comments.
lData.Name is typed as lData .Name
  the same for the function
lDate.AsString is typed as lData .AsString.
Notice the space before the dot...
-----------------  CUT  ---------------------
program project1;
{$mode objfpc}{$H+}
uses
  Classes;
type
  TMyClass = class(TObject)
  private
    FName: string;
  public
    property  Name: string read FName write FName;
    function  AsString: string;
  end;
{ TMyClass }
function TMyClass.AsString: string;
begin
  Writeln(Classname + '.Name: ' + FName);
end;
var
  lData: TMyClass;
begin
  lData := TMyClass.Create;
  try
    lData .Name := 'Graeme';   //  <== Why does this compile?
    lData .AsString;           //  <== Why does this compile?
  finally
    lData.Free;
  end;
end.
----------------  END  ----------------------
Regards,
  - Graeme -
    
    
More information about the fpc-devel
mailing list