Title: Fold a field projection through a foreign-header scope IIFE · Issue #159 · purescript-lua/purescript-lua · GitHub
Open Graph Title: Fold a field projection through a foreign-header scope IIFE · Issue #159 · purescript-lua/purescript-lua
X Title: Fold a field projection through a foreign-header scope IIFE · Issue #159 · purescript-lua/purescript-lua
Description: Golden.CharLiterals.Test's golden.lua (after #153) still contains this shape for Data.Eq.eqChar's foreign import, which declares a header (a local refEq = ... helper) alongside its exports: ((function() local refEq = function(r1) return ...
Open Graph Description: Golden.CharLiterals.Test's golden.lua (after #153) still contains this shape for Data.Eq.eqChar's foreign import, which declares a header (a local refEq = ... helper) alongside its exports: ((funct...
X Description: Golden.CharLiterals.Test's golden.lua (after #153) still contains this shape for Data.Eq.eqChar's foreign import, which declares a header (a local refEq = ... helper) alongside its exports:...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/159
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fold a field projection through a foreign-header scope IIFE","articleBody":"`Golden.CharLiterals.Test`'s golden.lua (after #153) still contains this shape for `Data.Eq.eqChar`'s foreign import, which declares a `header` (a `local refEq = ...` helper) alongside its exports:\n\n```lua\n((function()\n local refEq = function(r1) return function(r2) return r1 == r2 end end\n return { eqCharImpl = refEq }\nend)()).eqCharImpl\n```\n\nA `ForeignImport` with a header lowers to a chunk (`[ForeignSourceStat fh, return exportsTable]`), and any projection into one of its fields, `ObjectProp (ForeignImport ...) prop` in the IR, lowers through `asExpression`'s `chunkToExpression` into a call whose result is immediately projected: `(function() ...; return exportsTable end)().prop`.\n\nNeither the IR rule `reduceObjectProp` (#153) nor the Lua-AST rule `reduceTableDefinitionAccessor` sees through this, because the projected value is a function call, not a table constructor, at either level.\n\nThe rewrite is sound and general: for `Var (VarField (FunctionCall (Function [] body) []) prop)`, if the last statement of `body` is `Return e`, replacing it with `Return (varField e prop)` and keeping the leading statements ahead of it unchanged is equivalent. Projecting the field after the call returns versus before it returns is the same value, and no side effect crosses the call boundary since both happen within the same activation.\n\nThis only helps when a single field of a multi-export header is projected at a given call site; the header's other locals still get evaluated once per call site either way, same as today. That's an existing cost, not one this rewrite introduces.\n\nFound while implementing #153 (`Golden.CharLiterals.Test`, the `Data.Eq.eqChar` foreign import).\n","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-07-04T20:03:22Z","url":"https://github.com/purescript-lua/purescript-lua/issues/159"}
| 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:cfe15843-9b52-d7e3-b16a-a57e88b6ae05 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D45A:3F8AB1:8C8E09:B6AE9F:6B00DB67 |
| html-safe-nonce | b3f6e30609e97d18b0d3f511534e015239f31f1d0d0d6f0c71084c577e4686fd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENDVBOjNGOEFCMTo4QzhFMDk6QjZBRTlGOjZCMDBEQjY3IiwidmlzaXRvcl9pZCI6IjQ4MjQ3OTQ2NTI0MDgzMzkzMDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c05dfb7e49d435a7ad0316c829604748b11029dae55dd911b4bcd845f6df115d |
| hovercard-subject-tag | issue:4810381940 |
| 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/159/issue_layout |
| twitter:image | https://opengraph.githubassets.com/68bea15f68dbfaa84913bd11651aed540b3507b0083cb59511ef6bac2319f55b/purescript-lua/purescript-lua/issues/159 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/68bea15f68dbfaa84913bd11651aed540b3507b0083cb59511ef6bac2319f55b/purescript-lua/purescript-lua/issues/159 |
| og:image:alt | Golden.CharLiterals.Test's golden.lua (after #153) still contains this shape for Data.Eq.eqChar's foreign import, which declares a header (a local refEq = ... helper) alongside its exports: ((funct... |
| 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