Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2019-06

TPrimitiveExpr error when assign variable in an anonymous procedure inside a for loop

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Logan Ralston

Hi,

I've encountered a rather odd error in that whenever I attempt to assign a variable inside an anonymous procedure that is inside of a for loop, the program will not compile. However I can call a function that just sets the value of that variable and the program will compile (though I would prefer not to have to use this work around as it is quite bad form).

Example code:

for i := 0 to 10 do begin
      document.querySelector('#inputName').addEventListener('click',
procedure begin
         // Won't compile (citing TPrimitiveExpr not yet implemented error)
         someVariable := 5;
         // Works perfectly fine
         setSomeVariableToValue(5);
         // Works perfectly fine
         asm
            someVariable = 5;
         end;
      end);
end;

Does anyone know a way around this?

Thanks,
Logan Ralston
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20190605/dc89fcb1/attachment.html>

Reply by email

Mattias Gaertner
to Logan Ralston
Show quoted text 28 lines
Hi, I've encountered a rather odd error in that whenever I attempt to assign a variable inside an anonymous procedure that is inside of a for loop, the program will not compile. However I can call a function that just sets the value of that variable and the program will compile (though I would prefer not to have to use this work around as it is quite bad form). Example code: for i := 0 to 10 do begin document.querySelector('#inputName').addEventListener('click', procedure begin // Won't compile (citing TPrimitiveExpr not yet implemented error) someVariable := 5; // Works perfectly fine setSomeVariableToValue(5); // Works perfectly fine asm someVariable = 5; end; end); end; Does anyone know a way around this?

I fixed it in svn trunk and fixes.

Mattias

Reply by email

Logan Ralston

Thanks, Mattias:

As follow-up, since we're using TMS Web Core here, how do I go about integrating your trunk change under TMS' installation on Windows 10 running Delphi Rio 10.3.1? TMS appears to be out of sync with Pas2js and we want to keep the two in lock-step anyway (beyond being to test/use your trunk fixes). Please advise...

Appreciatively,

Logan Ralston
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20190606/1041f74c/attachment.html>

Reply by email

Michael Van Canneyt
to Logan Ralston
Logan Ralston wrote 7 lines
Thanks, Mattias: As follow-up, since we're using TMS Web Core here, how do I go about integrating your trunk change under TMS' installation on Windows 10 running Delphi Rio 10.3.1? TMS appears to be out of sync with Pas2js and we want to keep the two in lock-step anyway (beyond being to test/use your trunk fixes). Please advise...

Mattias can correct me if I am wrong:

TMS Software has a private version of the compiler dll with support for binary compiled units. So it can be that you have no choice but to use their version.

You could try to replace their version of libpas2js.dll with a freshly compiled free one one (I suspect this possibility is even required by the LGPL ?), but the consequence will be that the compiler needs to compile all sources from scratch at every compile.

Michael.

Reply by email

Ben Grasset
to Michael Van Canneyt
PM Michael Van Canneyt wrote
TMS Software has a private version of the compiler dll with support for binary compiled units. So it can be that you have no choice but to use their version.

Doesn't the normal trunk version have that same support?

TLibraryPas2JSCompiler descends from TPas2JSPCUCompiler <https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/pastojs/src/pas2jslibcompiler.pp?view=markup#l49>, at least.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20190606/02f4eb34/attachment.html>

Reply by email

Michael Van Canneyt
to Ben Grasset
Ben Grasset wrote 13 lines
On Thu, Jun 6, 2019 at 4:41 PM Michael Van Canneyt wrote: > TMS Software has a private version of the compiler dll with support for > binary compiled units. So it can be that you have no choice but to use > their version. > Doesn't the normal trunk version have that same support? TLibraryPas2JSCompiler descends from TPas2JSPCUCompiler <https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/pastojs/src/pas2jslibcompiler.pp?view=markup#l49>, at least.

This is not the same as the one used by TMS.

Michael.

Reply by email

Mattias Gaertner
to Michael Van Canneyt: Mattias can correct me if I am wrong: TMS Software has a private version of the compiler…
Show quoted text 20 lines
On Thu, 6 Jun 2019, Logan Ralston wrote: > Thanks, Mattias: > > As follow-up, since we're using TMS Web Core here, how do I go about > integrating your trunk change under TMS' installation on Windows 10 > running Delphi Rio 10.3.1? TMS appears to be out of sync with > Pas2js and we want to keep the two in lock-step anyway (beyond > being to test/use your trunk fixes). Please advise... Mattias can correct me if I am wrong: TMS Software has a private version of the compiler dll with support for binary compiled units. So it can be that you have no choice but to use their version. You could try to replace their version of libpas2js.dll with a freshly compiled free one one (I suspect this possibility is even required by the LGPL ?), but the consequence will be that the compiler needs to compile all sources from scratch at every compile.

Correct.

Mattias

Reply by email