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 (d44a71a) to head (49df497).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62892      +/-   ##
==========================================
+ Coverage   89.61%   89.63%   +0.01%     
==========================================
  Files         706      706              
  Lines      219203   219203              
  Branches    41995    42002       +7     
==========================================
+ Hits       196445   196472      +27     
+ Misses      14663    14634      -29     
- Partials     8095     8097       +2     
Files with missing lines Coverage Δ
lib/ffi.js 96.56% <100.00%> (ø)

... and 45 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.

@watilde
Copy link
Copy Markdown
Member Author

watilde commented Apr 23, 2026

rebase and make the commit Verified.

@watilde watilde requested a review from cjihrig April 23, 2026 11:23
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