[Pas2js] uncaught EAccessViolation during compiling typescript converted unit

Michael Van Canneyt michael at freepascal.org
Fri May 27 10:08:02 CEST 2022



On Thu, 26 May 2022, Emin Borbor wrote:

> Hi,
> I converted a Typescript definition using the latest dts2pas from trunk.
> When I try to compile the generated unit I get the following message
>
> bug: uncaught EAccessViolation: Access violation
> EAccessViolation: Access violation
> Compilation aborted
>
> Since it is a relatively large interface, I don't know how to debug the
> Pas2js compiler itself to find what is wrong. I would appreciate any advice.
>
> This is the converted unit from tabulator-tables/index.d.ts:
>
> https://www.dropbox.com/s/ydbiiy5ni17ilkr/libtabulatorjs.pas?dl=1
>

The problem is this:

TTabulator_download = Procedure (downloadType : jsvalue; fileName : string; params : TTabulator.TDownloadOptions; filter : TTabulator.TRowRangeLookup);

At this point, TTabulator is not yet defined fully and pas2js seems not to
handle this case correctly, it should give an 'identifier not found' error.

If you debug it, you indeed see that the crash happens in the resolver.

The solution is 2-fold:
- Move the definitions of the local types TDownloadOptions etc. forward
- Remove the TTabulator. in front of the type names.

Unfortunately, Typescript still allows so much variation in the declarations
that dts2pas cannot always generate a correct pascal declaration.

Michael.




More information about the Pas2js mailing list