Title: reduceObjectProp leaks the FFI @inline always annotation onto unrelated bindings, forcing unconditional duplication · Issue #169 · purescript-lua/purescript-lua · GitHub
Open Graph Title: reduceObjectProp leaks the FFI @inline always annotation onto unrelated bindings, forcing unconditional duplication · Issue #169 · purescript-lua/purescript-lua
X Title: reduceObjectProp leaks the FFI @inline always annotation onto unrelated bindings, forcing unconditional duplication · Issue #169 · purescript-lua/purescript-lua
Description: Problem Regression from #153 (reduceObjectProp, merged in #157). The Linker synthesizes exactly one shape carrying Just Inline.Always: a foreign name's alias binding, QName moduleName name = ObjectProp (Just Always) (Ref foreign) (PropNa...
Open Graph Description: Problem Regression from #153 (reduceObjectProp, merged in #157). The Linker synthesizes exactly one shape carrying Just Inline.Always: a foreign name's alias binding, QName moduleName name = Object...
X Description: Problem Regression from #153 (reduceObjectProp, merged in #157). The Linker synthesizes exactly one shape carrying Just Inline.Always: a foreign name's alias binding, QName moduleName name = Ob...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/169
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"reduceObjectProp leaks the FFI @inline always annotation onto unrelated bindings, forcing unconditional duplication","articleBody":"## Problem\n\nRegression from #153 (`reduceObjectProp`, merged in #157). The Linker synthesizes exactly one shape carrying `Just Inline.Always`: a foreign name's alias binding, `QName moduleName name = ObjectProp (Just Always) (Ref foreign) (PropName name)` (see Note [Foreign bindings structure emitted by the Linker] in `Linker.hs`). `isInlinableExpr` treats that annotation as \"always duplicate this expression at every use site\", bypassing the use-count check entirely.\n\n`reduceObjectProp` folds `ObjectProp _ann (LiteralObject _ props) prop` to `List.lookup prop props`, returning the field's value verbatim, annotation included. When a record literal has a field that happens to be one of these Linker-synthesized `Always`-marked foreign aliases, and something elsewhere projects that same field back out, the projection's result inherits `Just Always` even though the outer projection itself was never annotated. That annotation then becomes the root annotation of whatever binding the projection belongs to, making `isInlinableExpr` return `True` regardless of how many times that binding is actually used.\n\nConcretely, in `Golden.TailRecM2Shadow.Test`, the `Semiring Int` dictionary literal has `add: Data.Semiring.foreign.intAdd` as a field. The module's own top-level `add` binding projects that field out of the (inlined) dictionary and is referenced twice. Before #157, `add`'s root annotation stayed `Nothing`, so `add` correctly stayed a single shared top-level binding. After #157, the fold gives `add`'s root the dictionary field's own `Just Always`, so `add` is unconditionally duplicated at both call sites, and DCE then drops the now-unreferenced `Data.Semiring.foreign` table entirely — the foreign function's raw source ends up duplicated inline at each call site instead of one shared entry in the foreign import table:\n\n```lua\n-- before\nM.Golden_TailRecM2Shadow_Test_add = M.Data_Semiring_foreign.intAdd\na = M.Golden_TailRecM2Shadow_Test_add(o_S_31.a)(o_S_31.b)\n\n-- after\na = (function(x) return function(y) return x + y end end)(o_S_31.a)(o_S_31.b)\n```\n\nFor a foreign function with a nontrivial implementation this duplicates real code at every call site instead of one shared table entry.\n\n## Approach\n\nThe folded result must not inherit an annotation that was never meant to describe it. `reduceObjectProp` should discard the projected field's own annotation rather than letting it become the root annotation of the rewrite's result.\n\n## Prerequisites / Relations\n\nOptimizer bug, independent in the dependency graph. Related to #171 — both concern the interaction of the Linker's auto-`@inline always` annotation with the inliner — but distinct: this one is an annotation leak in `reduceObjectProp`, whereas #171 is the bare-`Ref` alias interaction.\n\n## Verification / Measurement\n\nProjecting a field whose value is an `Always`-marked foreign alias no longer marks the enclosing binding inlinable. In `Golden.TailRecM2Shadow.Test`, `add` stays a single shared top-level binding (`M.Golden_TailRecM2Shadow_Test_add = M.Data_Semiring_foreign.intAdd`) referenced from both call sites, rather than the foreign lambda being duplicated inline at each.\n","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-07-05T20:45:55Z","url":"https://github.com/purescript-lua/purescript-lua/issues/169"}
| 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:eaf74f51-e816-b8d7-c134-827df2f44623 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A56E:7A60E:90005A:BC2129:6B00DFBD |
| html-safe-nonce | 4ba0c189e0a3b1e52ba719b295d5852ab14bad69cc4ac93545f69811592239cd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTZFOjdBNjBFOjkwMDA1QTpCQzIxMjk6NkIwMERGQkQiLCJ2aXNpdG9yX2lkIjoiNDAzNzk3MjY3Njg5NDA1NjM4MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8cdeed6afade6cfa6bd49acf4c1597821532efccd80ca33d735fe228d990b50a |
| hovercard-subject-tag | issue:4814378300 |
| 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/169/issue_layout |
| twitter:image | https://opengraph.githubassets.com/003540ece17edc4d30277fabd3676ef13d7830030d7333c920ddc62b7dcbbe09/purescript-lua/purescript-lua/issues/169 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/003540ece17edc4d30277fabd3676ef13d7830030d7333c920ddc62b7dcbbe09/purescript-lua/purescript-lua/issues/169 |
| og:image:alt | Problem Regression from #153 (reduceObjectProp, merged in #157). The Linker synthesizes exactly one shape carrying Just Inline.Always: a foreign name's alias binding, QName moduleName name = Object... |
| 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