Title: Undefined variable in compiled code · Issue #37 · purescript-lua/purescript-lua · GitHub
Open Graph Title: Undefined variable in compiled code · Issue #37 · purescript-lua/purescript-lua
X Title: Undefined variable in compiled code · Issue #37 · purescript-lua/purescript-lua
Description: A compilation in some cases may produce invalid lua that is fails at runtime. I have not figured out what exactly causes this behavior but succeeded to catch some example. Example I tried my best to minimize it but can't find a way to ma...
Open Graph Description: A compilation in some cases may produce invalid lua that is fails at runtime. I have not figured out what exactly causes this behavior but succeeded to catch some example. Example I tried my best t...
X Description: A compilation in some cases may produce invalid lua that is fails at runtime. I have not figured out what exactly causes this behavior but succeeded to catch some example. Example I tried my best t...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/37
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Undefined variable in compiled code","articleBody":"A compilation in some cases may produce invalid lua that is fails at runtime.\nI have not figured out what exactly causes this behavior but succeeded to catch some example.\n \n## Example\nI tried my best to minimize it but can't find a way to make it smaller.\n```purs\nmodule Example (baz) where\n\nimport Effect (Effect)\nimport Prelude (class Monad, Unit, bind, discard, pure, unit)\n\nbaz ∷ Effect Unit\nbaz = bar (pure unit)\n\nbar ∷ ∀ f. Monad f ⇒ f Unit → f Unit\nbar f = do\n f\n _ ← pure [ foo f ]\n pure unit\n\nfoo ∷ ∀ f. Monad f ⇒ f Unit → f Unit\nfoo fn1 = do\n _ ← fn1\n fn1\n fn1\n fn1\n\n```\nRun via:\n```bash\npslua --foreign-path . --ps-output output--lua-output-file out.lua --entry Example\n```\n## Generated code\n```lua\n...\nreturn {\n baz = (function()\n return function(f)\n local Bind1 = M.Effect_monadEffect.Bind1()\n local pure = M.Control_Applicative_pure(M.Effect_monadEffect.Applicative0())\n return M.Example_discard(Bind1)(f)(function()\n return M.Control_Bind_bind(Bind1)(pure({\n [1] = (function()\n return function(fn1)\n local discard1 = M.Example_discard(Bind11) -- Bind11 is not in scope\n return M.Control_Bind_bind(M.Effect_monadEffect.Bind1())(fn1)(function( )\n return discard1(fn1)(function()\n return discard1(fn1)(function() return fn1 end)\n end)\n end)\n end\n end)()(f)\n }))(function() return pure(M.Data_Unit_foreign.unit) end)\n end)\n end\n end)()(M.Control_Applicative_pure(M.Effect_applicativeEffect)(M.Data_Unit_foreign.unit))\n}\n```\n\n## Version\npslua: [`684b8d2c32524394c51577636a258e71d00cfefb`](https://github.com/Unisay/purescript-lua/commit/684b8d2c32524394c51577636a258e71d00cfefb) (actual `master`)\n","author":{"url":"https://github.com/Renegatto","@type":"Person","name":"Renegatto"},"datePublished":"2025-10-09T19:51:00Z","url":"https://github.com/purescript-lua/purescript-lua/issues/37"}
| 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:032b6382-b0d0-06ca-8e68-0464a2d8e705 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC3A:1201C:7141F5:98B170:6B00D93A |
| html-safe-nonce | 017e46aca42ab0137f3d05c64d6c6f007b092b4a37a23a8b1a9b5dce2ca40eb2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzNBOjEyMDFDOjcxNDFGNTo5OEIxNzA6NkIwMEQ5M0EiLCJ2aXNpdG9yX2lkIjoiMjg4NDIyNjI5ODA0ODIwNzE2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 414b4b5b261ba0b30f1e08653e749218b31582f3ac8ddf8295aa77df2034835e |
| hovercard-subject-tag | issue:3500435209 |
| 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/37/issue_layout |
| twitter:image | https://opengraph.githubassets.com/87d20597865080e095634f4e355aad6369ecc5554d45c033f2bffa8dd939f7ba/purescript-lua/purescript-lua/issues/37 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/87d20597865080e095634f4e355aad6369ecc5554d45c033f2bffa8dd939f7ba/purescript-lua/purescript-lua/issues/37 |
| og:image:alt | A compilation in some cases may produce invalid lua that is fails at runtime. I have not figured out what exactly causes this behavior but succeeded to catch some example. Example I tried my best t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Renegatto |
| 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