View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0037238 | pas2js | transpiler | public | 2020-06-22 16:27 | 2020-10-23 11:56 |
Reporter | Sven Barth | Assigned To | Mattias Gaertner | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | assigned | Resolution | open | ||
Platform | x86_64 | OS | Win64 | ||
Product Version | trunk | ||||
Summary | 0037238: Compiler directive function "declared()" does not work correctly | ||||
Description | The 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". | ||||
Tags | No tags attached. | ||||
Fixed in Revision | |||||
Attached Files |
|
|
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. |
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 |