TObject.UnitName returns wrong result if declared in program
If the object is declared in the program and not in the unit, the UnitName method returns "program" instead of the program name.
program Project1;
{$mode objfpc}
uses
Classes, SysUtils;
type
TMyObj = class(TObject)
end;
var
O: TMyObj;
begin
O := TMyObj.Create;
Writeln(O.UnitName); // returns 'program' instead of 'Project1'
end.
Current behavior
The code aboves writes program
.
Expected behavior
The code should write Project1
(as FPC does).