ffi: use type errors for invalid signatures

Signed-off-by: HoonDongKang <d159123@naver.com>
PR-URL: https://github.com/nodejs/node/pull/66222
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
Donghoon Kang authored and GitHub committed 2026-09-25 18:58:21 +00:00
1 parent e76358e3f1
commit ad63e9ef29
2 files changed
+21 -3

No files matched your search

+18
View File
@@ -432,6 +432,24 @@ test('dynamic library APIs validate failures and bad signatures', () => {
lib.getFunction('add_i32', { return: 'i32', arguments: ['i32\0bad'] });
}, /Argument 0 of function add_i32 must not contain null bytes/);
assert.throws(() => {
lib.getFunction('add_i32', { return: 1, arguments: [] });
}, {
code: 'ERR_INVALID_ARG_TYPE',
});
assert.throws(() => {
lib.getFunction('add_i32', { return: 'i32', arguments: 'i32' });
}, {
code: 'ERR_INVALID_ARG_TYPE',
});
assert.throws(() => {
lib.getFunction('add_i32', { return: 'i32', arguments: [1] });
}, {
code: 'ERR_INVALID_ARG_TYPE',
});
assert.throws(() => {
lib.getFunctions('not an object');
}, {