how do i fix this node_dlang error?

Mike Parker aldacron at gmail.com
Sun Jun 6 17:32:57 UTC 2021


On Sunday, 6 June 2021 at 15:42:55 UTC, Jack wrote:
0.4.11\node_dlang\source\node_dlang.d(137,11): Error: none of the 
overloads of `this` are callable using argument types `(string, 
string, ulong, Throwable)`, candidates are:
> C:\D\dmd2\windows\bin\..\..\src\druntime\import\object.d(2440,30):        `object.Exception.this(string msg, string file = __FILE__, uint line = cast(uint)__LINE__, Throwable nextInChain = null)`
> C:\D\dmd2\windows\bin\..\..\src\druntime\import\object.d(2445,30):        `object.Exception.this(string msg, Throwable nextInChain, string file = __FILE__, uint line = cast(uint)__LINE__)`
> C:\D\dmd2\windows\bin\dmd.exe failed with exit code 1.
> ```

The error is from line 137 of node_dlang.d. Looking at it, we see 
this:

```d
super (message, file, line, nextInChain);
```

This is in the constructor of the `JSException` class, a subclass 
of `Exception`, calling the superclass constructor. According to 
the error message, one or more of the arguments in this list does 
not match any `Exception` constructor's parameter list.

Looking closer, we can see that the arguments to the super 
constructor are all declared in the `JSException` constructor 
like this:

```d
this (
     napi_value jsException
     , string message = `JS Exception`
     , string file = __FILE__
     , ulong line = cast (ulong) __LINE__
     , Throwable nextInChain = null)
```

Compare that with the constructors in the `Exception` class and 
you should see that the problem is `ulong line`. The equivalent 
argument in the superclass is `size_t`. In 32-bit, `size_t` is 
defined as `uint`, not `ulong`. So it's passing a `ulong` to a 
`uint`, which is a no-no.

The `JSException` constructor should be modified to this:

```d
, size_t line = __LINE__
```

The README does say it hasn't been tested with 32-bit. So there 
may be more such errors.

Unrelated, but I recommend you use `--arch=x86_mscoff` so that 
you can use the same linker and object file format as `-m64` uses 
(MS link, or lld, and PE/COFF), rather than the default (which is 
OPTLINK and OMF). It may save you further potential headaches.


More information about the Digitalmars-d-learn mailing list