Title: [fork-ffi] strings: drop the dead CodePoints fallbacks from linked output · Issue #270 · purescript-lua/purescript-lua · GitHub
Open Graph Title: [fork-ffi] strings: drop the dead CodePoints fallbacks from linked output · Issue #270 · purescript-lua/purescript-lua
X Title: [fork-ffi] strings: drop the dead CodePoints fallbacks from linked output · Issue #270 · purescript-lua/purescript-lua
Description: Problem Data.String.CodePoints passes PureScript-side fallback functions (singletonFallback, takeFallback, codePointAtFallback, countFallback, toCodePointArrayFallback, unsafeCodePointAt0Fallback, plus the plain unsafeCodePointAt0) into ...
Open Graph Description: Problem Data.String.CodePoints passes PureScript-side fallback functions (singletonFallback, takeFallback, codePointAtFallback, countFallback, toCodePointArrayFallback, unsafeCodePointAt0Fallback, ...
X Description: Problem Data.String.CodePoints passes PureScript-side fallback functions (singletonFallback, takeFallback, codePointAtFallback, countFallback, toCodePointArrayFallback, unsafeCodePointAt0Fallback, ...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/270
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[fork-ffi] strings: drop the dead CodePoints fallbacks from linked output","articleBody":"## Problem\n\n`Data.String.CodePoints` passes PureScript-side fallback functions (`singletonFallback`, `takeFallback`, `codePointAtFallback`, `countFallback`, `toCodePointArrayFallback`, `unsafeCodePointAt0Fallback`, plus the plain `unsafeCodePointAt0`) into its foreigns. The Lua FFI implements every operation natively and binds each fallback parameter to `_`; the fork's `CodePoints.lua` header states the fallbacks are written for UTF-16 code units and are wrong under this representation. The #186 audit confirmed every one of the 7 fallback slots is dead, yet the linker retains the fallback code because DCE cannot drop an argument to an opaque foreign call: in the committed `Golden.StringCodePoints.Test` golden the Fallback-named bindings alone are 108 lines / 4.4 kB, 16.9% of the linked output (a lower bound, since their transitive dependencies are not counted). The only recursive string concatenation in the whole package set lives inside these dead fallbacks, so it can never run, but it also never leaves the output.\n\n## Approach\n\nTwo candidate directions, pick one:\n\n1. **Fork-side stubs.** Replace the fallback definitions in the fork's `CodePoints.purs` with tiny `unsafeCrashWith`-style stubs (they are wrong-if-run today, so a loud crash is strictly safer than the current silent wrong result if a foreign ever started calling them). Cheap, ships with a strings release and a set bump, but diverges the fork's `.purs` from upstream and must be re-applied on upstream syncs.\n2. **Compiler-side dead-argument elimination.** Teach the backend that specific foreigns ignore specific arguments (an allowlist in the spirit of `ForeignLift`), so DCE can drop the dead argument expressions and everything only they reference. No fork divergence, benefits any future ignored-argument foreign, but is compiler work and needs a safe contract for what \"ignores\" means.\n\nThe fork-side stub is the pragmatic default; the compiler-side route subsumes it if the allowlist infrastructure is wanted anyway.\n\n## Prerequisites / Relations\n\nNo hard prerequisites. Found by the #186 audit (closed). The fork-side stub route is self-contained (strings patch release plus a set bump); the compiler-side route builds on the ForeignLift allowlist machinery introduced by #178 (closed).\n\n## Verification / Measurement\n\nLinked output for a CodePoints-using program no longer contains the fallback bodies (the `Golden.StringCodePoints.Test` golden shrinks by roughly the measured 16.9%), and eval goldens stay unchanged.\n","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-07-13T13:53:53Z","url":"https://github.com/purescript-lua/purescript-lua/issues/270"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:d5d61036-6335-954c-b41a-526972380eed |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BC28:EA09B:81BD33:ADFD11:6B00E060 |
| html-safe-nonce | 19a3d0c5c1f36e3a0435a40dfc654768da401bc17d47b46c0dfa380467ab4e01 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzI4OkVBMDlCOjgxQkQzMzpBREZEMTE6NkIwMEUwNjAiLCJ2aXNpdG9yX2lkIjoiMjQ0Mzc3NTY1ODA4NjY4NjgxNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3561d9f79b8ff46dfeb3d3ab4b53a2fdb9152c28a677b2cf43fed27375450872 |
| hovercard-subject-tag | issue:4874301178 |
| 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/purescript-lua/purescript-lua/270/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2e5a87bfadd1ed7cbf479742bf88a85c80b7f8582a6e23035dbb3e538b6dafd4/purescript-lua/purescript-lua/issues/270 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2e5a87bfadd1ed7cbf479742bf88a85c80b7f8582a6e23035dbb3e538b6dafd4/purescript-lua/purescript-lua/issues/270 |
| og:image:alt | Problem Data.String.CodePoints passes PureScript-side fallback functions (singletonFallback, takeFallback, codePointAtFallback, countFallback, toCodePointArrayFallback, unsafeCodePointAt0Fallback, ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Unisay |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| turbo-cache-control | no-preview |
| go-import | github.com/purescript-lua/purescript-lua git https://github.com/purescript-lua/purescript-lua.git |
| octolytics-dimension-user_id | 131581790 |
| octolytics-dimension-user_login | purescript-lua |
| octolytics-dimension-repository_id | 587200487 |
| octolytics-dimension-repository_nwo | purescript-lua/purescript-lua |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 587200487 |
| octolytics-dimension-repository_network_root_nwo | purescript-lua/purescript-lua |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width