Title: Note [Sequential scoping of Let bindings] omits freshenBinders and alphaKey from its list of implementors · Issue #354 · purescript-lua/purescript-lua · GitHub
Open Graph Title: Note [Sequential scoping of Let bindings] omits freshenBinders and alphaKey from its list of implementors · Issue #354 · purescript-lua/purescript-lua
X Title: Note [Sequential scoping of Let bindings] omits freshenBinders and alphaKey from its list of implementors · Issue #354 · purescript-lua/purescript-lua
Description: Problem pslua records how local bindings inside a Let resolve — sequentially, like Scheme's let* — as a GHC-style Note [Sequential scoping of Let bindings] in lib/Language/PureScript/Backend/IR/Types.hs. A Note is a named block comment t...
Open Graph Description: Problem pslua records how local bindings inside a Let resolve — sequentially, like Scheme's let* — as a GHC-style Note [Sequential scoping of Let bindings] in lib/Language/PureScript/Backend/IR/Typ...
X Description: Problem pslua records how local bindings inside a Let resolve — sequentially, like Scheme's let* — as a GHC-style Note [Sequential scoping of Let bindings] in lib/Language/PureScript/Backend/IR...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/354
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Note [Sequential scoping of Let bindings] omits freshenBinders and alphaKey from its list of implementors","articleBody":"## Problem\n\n`pslua` records how local bindings inside a `Let` resolve — sequentially, like Scheme's `let*` — as a GHC-style `Note [Sequential scoping of Let bindings]` in `lib/Language/PureScript/Backend/IR/Types.hs`. A `Note` is a named block comment that other sites reference by name instead of restating the rationale.\n\nThis Note is load-bearing rather than descriptive. It states that every traversal walking under `Let` binders while duplicate names can still occur must implement the convention, and that they must all agree — then enumerates the implementors:\n\n```\n * 'countFreeRefs' threads the scope through the groupings left to right;\n\n * 'alphaEq' resolves names to binder positions the same way, so it\n stays correct on shadowed input;\n\n * the well-scopedness lint\n ('Language.PureScript.Backend.IR.Linter.unboundLocals' — ...)\n tracks bound names the same way;\n\n * 'qualifyTopRefs' (Linker, ahead of the optimizer pipeline) decides\n whether a local reference escapes to a top-level binding by\n threading bound names the same way;\n\n * 'Language.PureScript.Backend.IR.Uniquify.uniquifyNamesInExpr'\n resolves names to fresh, site-wide unique names the same way, ...\n```\n\nTwo further traversals now implement the same rule and appear nowhere in that list:\n\n- `freshenBinders` (`Language.PureScript.Backend.IR.Optimizer`), the helper that renames a `Let`'s binders when a rewrite needs fresh names — corrected in #345 to walk the binders in scope order;\n- `alphaKey`, the function that computes the alpha-equivalence key used by common-subexpression elimination — corrected in #349 to key a `Let`'s binders in scope order.\n\nBoth reference the Note from their own Haddock, so the link runs one way only: a reader standing at the Note cannot see them. Since the list reads as exhaustive (\"they must all agree\"), the omission actively misleads — the next change to a scoping-sensitive traversal consults the Note, finds five implementors, and misses two.\n\nThis family has now produced three defects: #37, where an optimizer traversal resolved a sibling-bound reference against the wrong binder, DCE deleted the \"unused\" binder, and codegen emitted a dangling Lua variable (the Note cites it); then #345; then #349. The Note is the artifact meant to prevent the fourth.\n\n## Approach\n\nAdd the two missing implementors to the Note's bullet list, each with a one-clause statement of what it threads, in the style of the existing entries.\n\nAlso attach the obligation explicitly: a traversal that implements this convention must be listed here. Today the list is only implicitly exhaustive, which is why two additions slipped past it — stating the rule makes the omission a reviewable defect rather than an oversight.\n\nThe change edits a single comment block, so it is small enough to ride along in the next PR that touches a scoping-sensitive traversal instead of taking a cycle of its own.\n\n## Prerequisites / Relations\n\nNone. Follows #345 and #349, whose fixes created the omission.\n\n## Verification / Measurement\n\nEvery site whose Haddock claims to implement the convention appears in the Note's list. Documentation only — behaviour is already pinned by the golden test `test/ps/src/Golden/Issue37/Test.purs` and the \"Let sequential (let*) scoping\" tests, so this adds no test of its own.\n","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-07-29T12:55:22Z","url":"https://github.com/purescript-lua/purescript-lua/issues/354"}
| 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:feb1ab71-665a-c49e-804f-b000d6db9abf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E9E2:EA09B:6E08F3:93E65F:6B00D951 |
| html-safe-nonce | 4feecb25760df419b20b506856fd559455e49b02688908d99da4ea24ad2e1755 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOUUyOkVBMDlCOjZFMDhGMzo5M0U2NUY6NkIwMEQ5NTEiLCJ2aXNpdG9yX2lkIjoiNjEyNTA4NjQyNzc5MDIzNTk4NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d69eab43f652945e1dc0cbacfafa313ee3c4fe2d23e28bfe4934a4df51232eb1 |
| hovercard-subject-tag | issue:5009475069 |
| 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/354/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7000934ff0e7695e4bbfe1c80ff5ba5eb50b341f3791cb6a10b12b76e6ae8317/purescript-lua/purescript-lua/issues/354 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7000934ff0e7695e4bbfe1c80ff5ba5eb50b341f3791cb6a10b12b76e6ae8317/purescript-lua/purescript-lua/issues/354 |
| og:image:alt | Problem pslua records how local bindings inside a Let resolve — sequentially, like Scheme's let* — as a GHC-style Note [Sequential scoping of Let bindings] in lib/Language/PureScript/Backend/IR/Typ... |
| 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 | a481f62a1e04c9b9bdcb5628230682c66d59006f5b13b080f79cba84a176905b |
| 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 | 84c8c5cc25e2fb7f2308428458538436baecc6d2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width