René's URL Explorer Experiment


Title: fix: preserve order and scope of recursive groups in renameShadowedNames by Unisay · Pull Request #147 · purescript-lua/purescript-lua · GitHub

Open Graph Title: fix: preserve order and scope of recursive groups in renameShadowedNames by Unisay · Pull Request #147 · purescript-lua/purescript-lua

X Title: fix: preserve order and scope of recursive groups in renameShadowedNames by Unisay · Pull Request #147 · purescript-lua/purescript-lua

Description: Closes #133. renameShadowedNamesInExpr mishandled local recursive groups in two ways. The fold over group members consed each processed member onto an accumulator and never reversed the result, so every local RecursiveGroup came out with its members in reverse order. Member order is the initialization order computed by the laziness transform, so an eager member (for example the name = Lazy_name(0) forcing binding of a runtime-lazy group) could run before the member it reads was assigned, and the generated Lua crashed with "attempt to call a nil value". The second defect: each member's RHS was renamed in the scope accumulated over the previous members only, while recursive-group scoping makes every member visible in every member's RHS, itself included (see Note [Sequential scoping of Let bindings]). A group member that shadowed an outer binder had its self- and forward references quietly rebound to that outer binder, severing the recursion. The fix processes each group in two passes: first it brings all the members into scope (avoiding names bound anywhere in the group), then it renames every RHS in the complete group scope. Member order is preserved. Tests, written red first: Three unit tests in the "renames shadowed names" block cover order preservation, self-references and forward references. All three failed on the old code. A new golden module Golden.RecGroupOrder pins the runtime consequence. Its lazy self-reference (a reference under a lambda passed as a function argument, which the laziness analysis treats as potentially forced at initialization) compiles to a Lazy_record/record pair whose order is load-bearing. With the fix reverted, the generated Lua crashes with attempt to call local 'Lazy_record' (a nil value); with the fix it prints ok!. The Golden.RecursiveBindings churn is the reversal disappearing: member order now matches what the laziness transform emits. Both members there are lambdas, so the old order happened to be harmless.

Open Graph Description: Closes #133. renameShadowedNamesInExpr mishandled local recursive groups in two ways. The fold over group members consed each processed member onto an accumulator and never reversed the result, so ...

X Description: Closes #133. renameShadowedNamesInExpr mishandled local recursive groups in two ways. The fold over group members consed each processed member onto an accumulator and never reversed the result, so ...

Opengraph URL: https://github.com/purescript-lua/purescript-lua/pull/147

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,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-controllerpull_requests
route-actionfiles
fetch-noncev2:4d6991ba-fbe7-1e15-6d10-26474f0b7e6b
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idDCB6:76F02:DD2636:11D1614:6B00F9CC
html-safe-nonce6c52ac06d6951a117fbb9adeff6c323169dc29a9d3b30988531099288da190d2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQ0I2Ojc2RjAyOkREMjYzNjoxMUQxNjE0OjZCMDBGOUNDIiwidmlzaXRvcl9pZCI6IjI0ODQ0MTUwNzI0MzMxNDIyMjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmace3b3de30615839851a26db0cb9d452046bf7ff9d0ebfd76246a7bfa71807cbaf
hovercard-subject-tagpull_request:3981155104
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/purescript-lua/purescript-lua/pull/147/files
twitter:imagehttps://avatars.githubusercontent.com/u/1009751?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/1009751?s=400&v=4
og:image:altCloses #133. renameShadowedNamesInExpr mishandled local recursive groups in two ways. The fold over group members consed each processed member onto an accumulator and never reversed the result, so ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonee208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/purescript-lua/purescript-lua git https://github.com/purescript-lua/purescript-lua.git
octolytics-dimension-user_id131581790
octolytics-dimension-user_loginpurescript-lua
octolytics-dimension-repository_id587200487
octolytics-dimension-repository_nwopurescript-lua/purescript-lua
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id587200487
octolytics-dimension-repository_network_root_nwopurescript-lua/purescript-lua
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7dafd017fb7809a839c443dba08622af38e63c09
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/purescript-lua/purescript-lua/pull/147/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpurescript-lua%2Fpurescript-lua%2Fpull%2F147%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpurescript-lua%2Fpurescript-lua%2Fpull%2F147%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=purescript-lua%2Fpurescript-lua
Reloadhttps://github.com/purescript-lua/purescript-lua/pull/147/files
Reloadhttps://github.com/purescript-lua/purescript-lua/pull/147/files
Reloadhttps://github.com/purescript-lua/purescript-lua/pull/147/files
purescript-luahttps://github.com/purescript-lua
purescript-luahttps://github.com/purescript-lua/purescript-lua
Codehttps://github.com/purescript-lua/purescript-lua
Issues48 (48)https://github.com/purescript-lua/purescript-lua/issues
Pull requestshttps://github.com/purescript-lua/purescript-lua/pulls
Discussionshttps://github.com/purescript-lua/purescript-lua/discussions
Actionshttps://github.com/purescript-lua/purescript-lua/actions
Projectshttps://github.com/purescript-lua/purescript-lua/projects
Security and qualityhttps://github.com/purescript-lua/purescript-lua/security
Insightshttps://github.com/purescript-lua/purescript-lua/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fpurescript-lua%2Fpurescript-lua%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpurescript-lua%2Fpurescript-lua%2Fissues%2Fnew%2Fchoose
Unisayhttps://github.com/Unisay
mainhttps://github.com/purescript-lua/purescript-lua/tree/main
issue-133/rename-rec-groupshttps://github.com/purescript-lua/purescript-lua/tree/issue-133/rename-rec-groups
Conversation 1 https://github.com/purescript-lua/purescript-lua/pull/147
Commits 2 https://github.com/purescript-lua/purescript-lua/pull/147/commits
Checks 2 https://github.com/purescript-lua/purescript-lua/pull/147/checks
Files changed https://github.com/purescript-lua/purescript-lua/pull/147/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/147/files
fix: preserve order and scope of recursive groups in renameShadowedNames https://github.com/purescript-lua/purescript-lua/pull/147/files#top
Show all changes 2 commits https://github.com/purescript-lua/purescript-lua/pull/147/files
32899b0 fix: preserve order and scope of recursive groups in renameShadowedNa… Unisay Jul 2, 2026 https://github.com/purescript-lua/purescript-lua/pull/147/commits/32899b0bc7e7c31a578800d80af320b8dee52a78
41eccea docs: changelog fragment for the recursive-group rename fix (#133) Unisay Jul 2, 2026 https://github.com/purescript-lua/purescript-lua/pull/147/commits/41eccea4603e5a91d7797db10827d72e2dbd0c51
Clear filters https://github.com/purescript-lua/purescript-lua/pull/147/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/147/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/147/files
20260702_120000_unisay_rename_rec_groups.md https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-e2731cf093f8feff405314c4d3aec0d8510ec85b6b19f1dbc8aba760878f9a88
Optimizer.hs https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
Spec.hs https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-241ea2421c606c31b9414fb386f9f4d1beb60055ed792935b393101edfd7b949
corefn.json https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-3cc9397910428df93d0df7f2df2f1cb438462bdf5b875eb783d04783e39d56fe
.gitignore https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-dae531669e232d830dada6ff135b7a3f97c89c0d9f76c90a5eb77833e93a90a4
golden.txt https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-7822b76dd0c2573beb612ed31df73256d9126dc5fe143bed088ebff6562aafb1
golden.ir https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-bf2da045fb1b44f71351747a6a92d7e9e9aff7839fcc4cfe7164cf1ee02d50db
golden.lua https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-72af85a05100e41c0bb4d21b300777c481629f733f4af789195ba61dd84c1b9b
golden.ir https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-8d033027fc53cb99d91b379e4ee2de7b079e1d3343fe598fba51211692d8cebf
golden.lua https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-1b0c45cacd09fb2b63dc94b7c30abbd79d0e933acd8f6c16b66594440df4f9a6
Test.purs https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-f0c41ad00f03b5c392fc2c44c34ba3b8ddeecc42619f2e37ab874fb8012ec998
changelog.d/20260702_120000_unisay_rename_rec_groups.mdhttps://github.com/purescript-lua/purescript-lua/pull/147/files#diff-e2731cf093f8feff405314c4d3aec0d8510ec85b6b19f1dbc8aba760878f9a88
View file https://github.com/purescript-lua/purescript-lua/blob/41eccea4603e5a91d7797db10827d72e2dbd0c51/changelog.d/20260702_120000_unisay_rename_rec_groups.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/147/{{ revealButtonHref }}
lib/Language/PureScript/Backend/IR/Optimizer.hshttps://github.com/purescript-lua/purescript-lua/pull/147/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
View file https://github.com/purescript-lua/purescript-lua/blob/41eccea4603e5a91d7797db10827d72e2dbd0c51/lib/Language/PureScript/Backend/IR/Optimizer.hs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/147/{{ revealButtonHref }}
https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
test/Language/PureScript/Backend/IR/Optimizer/Spec.hshttps://github.com/purescript-lua/purescript-lua/pull/147/files#diff-241ea2421c606c31b9414fb386f9f4d1beb60055ed792935b393101edfd7b949
View file https://github.com/purescript-lua/purescript-lua/blob/41eccea4603e5a91d7797db10827d72e2dbd0c51/test/Language/PureScript/Backend/IR/Optimizer/Spec.hs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/147/{{ revealButtonHref }}
https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-241ea2421c606c31b9414fb386f9f4d1beb60055ed792935b393101edfd7b949
https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-241ea2421c606c31b9414fb386f9f4d1beb60055ed792935b393101edfd7b949
https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-241ea2421c606c31b9414fb386f9f4d1beb60055ed792935b393101edfd7b949
https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-241ea2421c606c31b9414fb386f9f4d1beb60055ed792935b393101edfd7b949
test/ps/output/Golden.RecGroupOrder.Test/corefn.jsonhttps://github.com/purescript-lua/purescript-lua/pull/147/files#diff-3cc9397910428df93d0df7f2df2f1cb438462bdf5b875eb783d04783e39d56fe
View file https://github.com/purescript-lua/purescript-lua/blob/41eccea4603e5a91d7797db10827d72e2dbd0c51/test/ps/output/Golden.RecGroupOrder.Test/corefn.json
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/147/{{ revealButtonHref }}
test/ps/output/Golden.RecGroupOrder.Test/eval/.gitignorehttps://github.com/purescript-lua/purescript-lua/pull/147/files#diff-dae531669e232d830dada6ff135b7a3f97c89c0d9f76c90a5eb77833e93a90a4
View file https://github.com/purescript-lua/purescript-lua/blob/41eccea4603e5a91d7797db10827d72e2dbd0c51/test/ps/output/Golden.RecGroupOrder.Test/eval/.gitignore
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/147/{{ revealButtonHref }}
test/ps/output/Golden.RecGroupOrder.Test/eval/golden.txthttps://github.com/purescript-lua/purescript-lua/pull/147/files#diff-7822b76dd0c2573beb612ed31df73256d9126dc5fe143bed088ebff6562aafb1
View file https://github.com/purescript-lua/purescript-lua/blob/41eccea4603e5a91d7797db10827d72e2dbd0c51/test/ps/output/Golden.RecGroupOrder.Test/eval/golden.txt
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/147/{{ revealButtonHref }}
test/ps/output/Golden.RecGroupOrder.Test/golden.irhttps://github.com/purescript-lua/purescript-lua/pull/147/files#diff-bf2da045fb1b44f71351747a6a92d7e9e9aff7839fcc4cfe7164cf1ee02d50db
View file https://github.com/purescript-lua/purescript-lua/blob/41eccea4603e5a91d7797db10827d72e2dbd0c51/test/ps/output/Golden.RecGroupOrder.Test/golden.ir
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/147/{{ revealButtonHref }}
test/ps/output/Golden.RecGroupOrder.Test/golden.luahttps://github.com/purescript-lua/purescript-lua/pull/147/files#diff-72af85a05100e41c0bb4d21b300777c481629f733f4af789195ba61dd84c1b9b
View file https://github.com/purescript-lua/purescript-lua/blob/41eccea4603e5a91d7797db10827d72e2dbd0c51/test/ps/output/Golden.RecGroupOrder.Test/golden.lua
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/147/{{ revealButtonHref }}
test/ps/output/Golden.RecursiveBindings.Test/golden.irhttps://github.com/purescript-lua/purescript-lua/pull/147/files#diff-8d033027fc53cb99d91b379e4ee2de7b079e1d3343fe598fba51211692d8cebf
View file https://github.com/purescript-lua/purescript-lua/blob/41eccea4603e5a91d7797db10827d72e2dbd0c51/test/ps/output/Golden.RecursiveBindings.Test/golden.ir
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/147/{{ revealButtonHref }}
https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-8d033027fc53cb99d91b379e4ee2de7b079e1d3343fe598fba51211692d8cebf
https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-8d033027fc53cb99d91b379e4ee2de7b079e1d3343fe598fba51211692d8cebf
https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-8d033027fc53cb99d91b379e4ee2de7b079e1d3343fe598fba51211692d8cebf
https://github.com/purescript-lua/purescript-lua/pull/147/files#diff-8d033027fc53cb99d91b379e4ee2de7b079e1d3343fe598fba51211692d8cebf
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/147/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/147/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.