Title: ffi: bool changes from uint8 to Boolean after Fast API optimization · Issue #64526 · nodejs/node · GitHub
Open Graph Title: ffi: bool changes from uint8 to Boolean after Fast API optimization · Issue #64526 · nodejs/node
X Title: ffi: bool changes from uint8 to Boolean after Fast API optimization · Issue #64526 · nodejs/node
Description: Version main Platform macOS 26.5.2 Subsystem ffi What steps will reproduce the bug? add.c #include
Open Graph Description: Version main Platform macOS 26.5.2 Subsystem ffi What steps will reproduce the bug? add.c #include
X Description: Version main Platform macOS 26.5.2 Subsystem ffi What steps will reproduce the bug? add.c #include <stdint.h> uint8_t add_u8(uint8_t a, uint8_t b) { return a + b; } Build the file $ cc -dynam...
Opengraph URL: https://github.com/nodejs/node/issues/64526
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ffi: bool changes from uint8 to Boolean after Fast API optimization","articleBody":"### Version\n\nmain\n\n### Platform\n\n```text\nmacOS 26.5.2\n```\n\n### Subsystem\n\nffi\n\n### What steps will reproduce the bug?\n\n`add.c`\n```c\n#include \u003cstdint.h>\n\nuint8_t add_u8(uint8_t a, uint8_t b) {\n return a + b;\n}\n```\n\nBuild the file\n```sh\n$ cc -dynamiclib add.c -o libadd.dylib\n```\n\nUse in `repro.js`\n```js\nimport { dlopen } from 'node:ffi';\n\nconst handle = dlopen(`./libadd.dylib`, {\n add_u8: {\n arguments: ['bool', 'bool'],\n return: 'bool',\n },\n});\n\nconst native = handle.functions.add_u8;\n\nfunction fn(a, b) {\n return native(a, b);\n}\n\neval('%PrepareFunctionForOptimization(fn)');\n\nlet result = fn(1, 0);\nconsole.log('unoptimized:', result, typeof result);\n\neval('%OptimizeFunctionOnNextCall(fn)');\n\nresult = fn(1, 0);\nconsole.log('optimized:', result, typeof result);\n\nresult = fn(true, false);\nconsole.log('booleans:', result, typeof result);\n```\n\nRun\n```console\n$ node --experimental-ffi --allow-natives-syntax --no-warnings repro.js\n```\n\n\n### How often does it reproduce? Is there a required condition?\n\nAlways\n\n### What is the expected behavior? Why is that the expected behavior?\n\n```console\nunoptimized: 1 number\noptimized: 1 number\nTypeError: Argument 0 must be a uint8\n```\n\nThe optimized numeric call should behave exactly like the unoptimized call.\nThe final `fn(true, false)` call should throw `ERR_INVALID_ARG_VALUE`.\n\n### What do you see instead?\n\n```console\nunoptimized: 1 number\noptimized: true boolean\nbooleans: true boolean\n```\n\nAfter JIT optimization, the return type changes from numeric `uint8` to Boolean, and Boolean arguments become accepted\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/trivikr","@type":"Person","name":"trivikr"},"datePublished":"2026-07-16T03:24:14Z","url":"https://github.com/nodejs/node/issues/64526"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bc63b29d-ff69-093f-4c25-845bae9ea5ff |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AE56:5463F:76FE3E:A0DFA9:6AED2C1A |
| html-safe-nonce | ce0662b98a7a63e10526b46197759cf5daca14fb20f556c391d9a701ef8f17f4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTU2OjU0NjNGOjc2RkUzRTpBMERGQTk6NkFFRDJDMUEiLCJ2aXNpdG9yX2lkIjoiODA3MTc4NDM2MTkwNTQzMzYyNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4ae11883e7c9c0ff7c099c3fd8304138002747013093b460ea0e004cc808c172 |
| hovercard-subject-tag | issue:4898381489 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/64526/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a0241ab3a9ca067dba759f752cda3c4305a19f6a7038df86aa2dac97c445f10f/nodejs/node/issues/64526 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a0241ab3a9ca067dba759f752cda3c4305a19f6a7038df86aa2dac97c445f10f/nodejs/node/issues/64526 |
| og:image:alt | Version main Platform macOS 26.5.2 Subsystem ffi What steps will reproduce the bug? add.c #include |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | trivikr |
| hostname | github.com |
| expected-hostname | github.com |
| None | e51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 59ebb7b901cc154ecc179a44f266fcf69f343b30 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width