Program doesn't compile

Issue #68 wontfix
Former user created an issue

I'm use Intellij Idea 2017.3 and freePascal 3.0.2. I have simple program:

program test;

Type
    TPerson = class
        fAge: Integer;
        fName: String;
        procedure setAge(Age: Integer);
        function sayName: string;
        constructor Create();
        destructor Destroy();
    end;

{ TPerson }

procedure TPerson.setAge(Age: Integer);
begin
    if Age > 0 then fAge := Age ;

end;

function TPerson.sayName: string;
begin
    Result := ('My name is ' + fName);
end;

constructor TPerson.Create();
begin
    fAge := 10;
    fName := 'Person'
end;

destructor TPerson.Destroy();
begin
    fAge := 0;
    fName := '';
end;

var
    Man: TPerson;

begin
    Man := TPerson.Create();
    Man.fName := 'anton';
    Man.fAge := 27;
    WriteLn(man.sayName());
    Man.Destroy()
end.

But, when I try to compile this program, I get the error: Error:(9, 15) Pascal builder: Identifier not found "class" Error:(10, 9) Pascal builder: Error in type definition Error:(10, 9) Pascal builder: Syntax error, ";" expected but "identifier FAGE" found

And this code is compile in Pascal ABC

Comments (1)

  1. George Bakhtadze repo owner

    Free Pascal can't compile this code because default syntax mode is FPC which doesn't support classes. Add {$MODE DELPHI} at the beginning and it will compile.

    I'll consider to add default syntax mode option to SDK.

  2. Log in to comment