View Issue Details

IDProjectCategoryView StatusLast Update
0037238pas2jstranspilerpublic2020-10-23 11:56
ReporterSven Barth Assigned ToMattias Gaertner  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
Platformx86_64OSWin64 
Product Versiontrunk 
Summary0037238: Compiler directive function "declared()" does not work correctly
DescriptionThe compiler directive function "declared()" (see https://freepascal.org/docs-html/current/prog/progsu127.html#x140-1410002.4.1 ) does not handle any identifiers correctly. See attached example that compiles correctly with FPC (with variations of the NO_* defines set), but not with pas2js, which always returns with the error "p2jtests\tdeclared.pp(43,26) Error: "function" expected, but ")" found".
TagsNo tags attached.
Fixed in Revision
Attached Files

Activities

Sven Barth

2020-06-22 16:27

developer  

tdeclared.pp (1,198 bytes)   
program tdeclared;

{$mode objfpc}

{$ifndef NO_TESTCONST}
const
  TestConst = 42;
{$endif}

{$ifndef NO_TESTVAR}
var
  TestVar: LongInt = 42;
{$endif}

{$ifndef NO_TESTFUNC}
function TestFunc: LongInt;
begin
  Result := 0;
end;
{$endif}

{$ifndef NO_TESTPROC}
procedure TestProc;
begin
end;
{$endif}

{$ifndef NO_TESTTYPE}
type
  TestType = class

  end;
{$endif}

{$ifndef NO_GENTESTTYPE}
type
  generic GenTestType<S, T> = class

  end;
{$endif}

begin
{$if declared(TestConst)}
  Writeln('TestConst exists');
{$else}
  Writeln('TestConst not exists');
{$endif}

{$if declared(TestVar)}
  Writeln('TestVar exists');
{$else}
  Writeln('TestVar not exists');
{$endif}

{$if declared(TestFunc)}
  Writeln('TestFunc exists');
{$else}
  Writeln('TestFunc not exists');
{$endif}

{$if declared(TestProc)}
  Writeln('TestProc exists');
{$else}
  Writeln('TestProc not exists');
{$endif}

{$if declared(TestType)}
  Writeln('TestType exists');
{$else}
  Writeln('TestType not exists');
{$endif}

{$if declared(GenTestType<,>)}
  Writeln('GenTestType<,> exists');
{$else}
  Writeln('GenTestType<,> not exists');
{$endif}
end.
tdeclared.pp (1,198 bytes)   

Issue History

Date Modified Username Field Change
2020-06-22 16:27 Sven Barth New Issue
2020-06-22 16:27 Sven Barth File Added: tdeclared.pp
2020-10-23 11:56 Mattias Gaertner Assigned To => Mattias Gaertner
2020-10-23 11:56 Mattias Gaertner Status new => assigned