"Cannot read property of null" - Using class functions

The following example generates the outlined error. This works 100% as expected in a normal VCL project in the Delphi IDE.

THelloWorld = class
private
class function SayIt: String; static;
end;

TGreetings = class
private
class function Greet: THelloWorld; static;
end;

TForm1 = class(TWebForm)
WebButton1: TWebButton;
procedure WebButton1Click(Sender: TObject);
end;

procedure TForm1.WebButton1Click(Sender: TObject);
begin
TGreetings.Greet;
end;

class function TGreetings.Greet: THelloWorld;
begin
ShowMessage(Result.SayIt);
end;

class function THelloWorld.SayIt: String;
begin
Result := 'Hello World!';
end;


You can also not implement the same concept using a "class var". Here's an example:


THelloWorld = class
private
class function SayIt: String; static;
end;

TForm1 = class(TWebForm)
WebButton1: TWebButton;
procedure WebButton1Click(Sender: TObject);
class var
fHelloWorld : THelloWorld;
end;

procedure TForm1.WebButton1Click(Sender: TObject);
begin
ShowMessage(fHelloWorld.SayIt);
end;

class function THelloWorld.SayIt: String;
begin
Result := 'Hello World!';
end;

An error is produced "Cannot read property {xxx} of null".

This seems like a bug in Visual Studio for TMS WEB Core. Please advise?

Thank you.

This looks to be a pas2js compiler issue. We will report this to the pas2js team.