<div dir="ltr">
<p>Hello Pas2JS and TMS Teams -<br></p><p>The following cruelty was discovered during a protracted TDD session
and after a bout of OCD in which I simply had to right-justify all my
[nested] compile-time directives. This problem was first observed using
Pas2JS Compiler version 1.0.0rc1 [2018/07/25] for Win32 i386 when
developing with TMS WEB Core version v1.0.0.3 on RAD Studio/Delphi
Enterprise v10.2.3.</p>
<p>Viewing the <a>Pas2js_Issue_20180814.lpr</a>
unit below (and a screen grab of its resulting output in the browser's
console), note that Pas2js wrongly and, worse yet, silently "cares"
about the number of spaces within a compiler directive (one space is
good; two or more are bad). With [THAT] said, I think [THIS] should be fixed
as all directives, except switch directives, must have at least one
space (<strong><em>but may have more</em></strong>) between the
directive name and its parameter(s). This was otherwise a tricky bug to quash being non-obvious as well as nonsensical.</p><p>Regards,</p><p>J Ralston<br>Frameworks<br></p>
<h2 id="gmail-pas2js_issue_20180814-lpr-source-file-">Pas2js_Issue_20180814.lpr (source file attached)</h2>
<pre><code class="gmail-lang-!Pas2js">program Pas2js_Issue_20180814;
uses WEB;
begin
{$define THIS}{<-- apparently Pas2js cares about the extra space before THIS}
{$define THAT}
{$ifdef THIS}
console.log( 'Strangely, THIS will NOT print with the following statement.' );
console.log( 'Per Object Pascal conventions, all directives, except switch '
+ 'directives, must have at least one space (but may have more) '
+ 'between the directive name and its parameter(s).' );
{$endif}
{$ifdef THIS}{<-- yet, correctly, Pas2js doesn't care about it here}
console.log( 'Also, THIS will NOT print.' );
{$endif}
{$if defined( THIS) or defined(THIS)}{<-- nor here}
console.log( 'Neither will THIS print either.' );
{$endif}
{$ifdef THAT}
console.log( 'Per Object Pascal conventions, all directives, except switch '
+ 'directives, must have at least one space (but may have more) '
+ 'between the directive name and its parameter(s).' );
console.log( 'With THAT understood, the above did print.' );
{$endif}
{$if defined( THAT) and defined(THAT)}{<-- nor here}
console.log( 'Like a day, what a difference a single space can make!' );
console.log( 'Now I wonder how many such directives are being ignored globally?' );
{$endif}
end.
</code></pre>
<h2 id="gmail-pas2js_issue_20180814-html-browser-launch-file-">Pas2js_Issue_20180814.html (browser launch file)</h2>
<pre><code class="gmail-lang-!HTML"><html>
<head>
<meta charset="utf-8"/>
<title>Pas2js Issue 20180814</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="Pas2JS Issue Report"/>
<meta name="keywords" content="Issues,Pas2JS,Pascal,JavaScript"/>
<meta name="author" content="J Ralston"/>
<meta name="company" content="Frameworks"/>
<script type="application/javascript" src="Pas2js_Issue_20180814.js"></script>
</head>
<body>
<script type="application/javascript">
rtl.run();
</script>
</body>
</html>
</code></pre>
<h2 id="gmail-browser-s-console-output">Browser's Console Output</h2>
<ul>
</ul>(Related JavaScript produced with Pas2JS Compiler version 1.0.0 [2018/08/09] for Win32 i386)<br><div>
<p></p><div><img src="cid:ii_jkubv5k40_1653abb585123eb2" width="530" height="188"><br></div><p></p>
<p>This issue has been further investigated and reproduced directly
using the Pas2JS Compiler version 1.0.0 [2018/08/09] for Win32 i386
(with neither Delphi nor TMS WEB Core present).</p>
<p>Separately of note here due to a shared compiler code base, this issue has not been investigated on FPC but perhaps should be.</p>
<br></div></div>