Do what GJS does and log a warning to stderr and then do nothing (pretend the function was never called).
Throw a JS error with a message detailing what was expected and what was given.
I'm a fan of the strictness being enforced by option 2 but GJS is lenient in this regard by just logging an error and then not doing the native call.
Personally I think option 1 can lead to harder to solve bugs. While GJS does log a very small stack trace this is not the same as a real uncaught error from the engine itself. It will not trigger tooling around uncaught errors that a nodejs program might have such as process.on('uncaughtException', ...);, and if the program has noisy output if can become very difficult to see the tree from the forest. Clearly i'm biased towards option 2 but this is easy to change so i've created this issue incase someone has some good reasons I may have missed!
When JS calls native functions but passes incorrect arguments how strict should the bindings be?
example:
Should the invalid arguments call result in:
stderr
and then do nothing (pretend the function was never called).I'm a fan of the strictness being enforced by option 2 but GJS is lenient in this regard by just logging an error and then not doing the native call.
Personally I think option 1 can lead to harder to solve bugs. While GJS does log a very small stack trace this is not the same as a real uncaught error from the engine itself. It will not trigger tooling around uncaught errors that a nodejs program might have such as
process.on('uncaughtException', ...);
, and if the program has noisy output if can become very difficult to see the tree from the forest. Clearly i'm biased towards option 2 but this is easy to change so i've created this issue incase someone has some good reasons I may have missed!