Title: Keep the projection's annotation when folding a record projection by Unisay · Pull Request #193 · purescript-lua/purescript-lua · GitHub
Open Graph Title: Keep the projection's annotation when folding a record projection by Unisay · Pull Request #193 · purescript-lua/purescript-lua
X Title: Keep the projection's annotation when folding a record projection by Unisay · Pull Request #193 · purescript-lua/purescript-lua
Description: Fixes #169. The leak reduceObjectProp folded { foo: v }.foo to v verbatim, root annotation included. The Linker marks exactly one shape with Just Always: a foreign accessor alias, ObjectProp (Just Always) (Ref foreign) (PropName name) (see Note [Foreign bindings structure emitted by the Linker]). The leak takes three hops: the inliner copies such an accessor into a record literal's field (a typeclass dictionary), something projects that field back out, and the fold hands the field's Just Always to the result. That annotation then becomes the root annotation of whatever binding received the fold, so isInlinableExpr passes unconditionally: the binding gets duplicated at every use site and dropped from the uber-module bindings, regardless of its use count. The fix The fold result now carries the projection node's own annotation. This needed a new setAnn in IR.Types (the symmetric setter to getAnn; nothing on main could replace a root annotation without touching the rest of the tree), applied on both the LiteralObject and ObjectUpdate paths. Why the projection's annotation and not a plain reset to noAnn: the rewrite result occupies the projection's position in the tree, and the fall-through ObjectUpdate branch already keeps ann. A reset would also silently swallow an explicit user @inline pragma placed on the projection. A test pins this choice: a field annotated Just Always projected by a node annotated Just Never folds to a Just Never result, which distinguishes the fix both from the bug (Just Always) and from the reset variant (Nothing). Tests, demonstrated red first Three rule-level tests (leak out of a record literal, leak out of an update patch, the semantics pin above) and one UberModule-level test: a binding referenced twice whose RHS folds to an Always-annotated field must survive optimizedUberModule. All four failed before the fix (the first two returned Just Always) and pass after it. Goldens No golden changed. The issue predicted that Golden.TailRecM2Shadow.Test would get its shared add binding back, but on current main that chain no longer routes the leaked annotation through a shared binding: optimizer changes merged since the issue was filed reshaped it. I verified this directly by running the golden on a pre-fix build; its output is identical to the fixed build's. The leak is latent on the committed test programs, which is why the regression tests pin it at the rule and pipeline level instead. The eval/golden.txt oracles are untouched. Relations Related to #171, which concerns the same Linker Just Always annotation but a different interaction (the bare Ref alias), and stays open.
Open Graph Description: Fixes #169. The leak reduceObjectProp folded { foo: v }.foo to v verbatim, root annotation included. The Linker marks exactly one shape with Just Always: a foreign accessor alias, ObjectProp (Just ...
X Description: Fixes #169. The leak reduceObjectProp folded { foo: v }.foo to v verbatim, root annotation included. The Linker marks exactly one shape with Just Always: a foreign accessor alias, ObjectProp (Just ...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/pull/193
X: @github
Domain: github.com
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:e17a1595-2f13-49a9-0fb3-ca1023d6b83a |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8F28:3E4205:A607EC:DFAFA7:6B00EFB4 |
| html-safe-nonce | 51d738a181fc411907779b9ad7198ed0fe6900b66a37fc7281ea385541076787 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RjI4OjNFNDIwNTpBNjA3RUM6REZBRkE3OjZCMDBFRkI0IiwidmlzaXRvcl9pZCI6IjY1NDQ2OTg3NDU0MjUwMzEwOTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8c751ad5bbd69e2cbe72da5c033a9d2b3d57a1881c065ad1a4730657258a2282 |
| hovercard-subject-tag | pull_request:4000987184 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/purescript-lua/purescript-lua/pull/193/files |
| twitter:image | https://avatars.githubusercontent.com/u/1009751?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1009751?s=400&v=4 |
| og:image:alt | Fixes #169. The leak reduceObjectProp folded { foo: v }.foo to v verbatim, root annotation included. The Linker marks exactly one shape with Just Always: a foreign accessor alias, ObjectProp (Just ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width