[Pas2js] Nested functions or procedures

Michael Van Canneyt michael at freepascal.org
Mon Dec 14 11:58:33 CET 2020



On Mon, 14 Dec 2020, heliosroots wrote:

> I am not able to use a nested function, if it is nested in a pascal class, I
> do not know if this behavior is normal. It works if it is nested in a simple
> function.
>
> procedure AnimationFrame(ATime: double = 0); 
> begin
>   ...
>   window.requestAnimationFrame(@AnimationFrame);
> end;
>
>
> ///Error: Incompatible type arg no. 1: Got "procedure(Double) of Object",
> expected "procedure(Double)"

It depends on how the requestAnimationFrame was defined.

Change the definition on line 1993 of web.pas to

  TFrameRequestCallback = reference to procedure (aTime: TJSDOMHighResTimeStamp);

And it will work with both kinds of procedure.

I fixed it in SVN, rev. 1013.

Michael.


More information about the Pas2js mailing list