Skip to content

ffi: fix FLOAT_32 and FLOAT_64 type constants#62892

Open
watilde wants to merge 1 commit intonodejs:mainfrom
watilde:ffi-fixes
Open

ffi: fix FLOAT_32 and FLOAT_64 type constants#62892
watilde wants to merge 1 commit intonodejs:mainfrom
watilde:ffi-fixes

Conversation

@watilde
Copy link
Copy Markdown
Member

@watilde watilde commented Apr 22, 2026

Test code

$ cat test.js
const ffi = require('node:ffi');

const { functions } = ffi.dlopen('libm.so.6', {
  sinf: { parameters: [ffi.types.FLOAT_32], result: ffi.types.FLOAT_32 },
});

console.log(functions.sinf(1.0));

Before

$ ./node --experimental-ffi test.js
node:ffi:75
    throw error;
    ^

TypeError: Unsupported FFI type: float32
    at Object.dlopen (node:ffi:71:91)
    at Object.<anonymous> (/home/moku/Developments/watilde/node/test.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1829:14)
    at Object..js (node:internal/modules/cjs/loader:1969:10)
    at Module.load (node:internal/modules/cjs/loader:1552:32)
    at Module._load (node:internal/modules/cjs/loader:1354:12)
    at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
    at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
    at node:internal/main/run_main_module:33:47 {
  code: 'ERR_INVALID_ARG_VALUE'
}

Node.js v26.0.0-pre

After

$ ./node --experimental-ffi test.js
0.8414709568023682
(node:721215) ExperimentalWarning: FFI is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

@nodejs-github-bot nodejs-github-bot added ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run. labels Apr 22, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.63%. Comparing base (3a53447) to head (843d824).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62892      +/-   ##
==========================================
+ Coverage   89.60%   89.63%   +0.02%     
==========================================
  Files         706      706              
  Lines      219179   219179              
  Branches    41993    41998       +5     
==========================================
+ Hits       196400   196452      +52     
+ Misses      14675    14627      -48     
+ Partials     8104     8100       -4     
Files with missing lines Coverage Δ
lib/ffi.js 96.56% <100.00%> (ø)

... and 33 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants