Title: [fork-ffi] enums: toCharCode crashes on a lone code-unit byte (regression in v6.1.1) · Issue #102 · purescript-lua/purescript-lua · GitHub
Open Graph Title: [fork-ffi] enums: toCharCode crashes on a lone code-unit byte (regression in v6.1.1) · Issue #102 · purescript-lua/purescript-lua
X Title: [fork-ffi] enums: toCharCode crashes on a lone code-unit byte (regression in v6.1.1) · Issue #102 · purescript-lua/purescript-lua
Description: The v6.1.1 toCharCode rewrite (#79) assumed every Char value is a complete UTF-8 sequence and unconditionally read c:byte(2..4). But Data.String.CodeUnits slices a String byte-wise (toCharArray = s:sub(i,i), one byte each) and lets Data....
Open Graph Description: The v6.1.1 toCharCode rewrite (#79) assumed every Char value is a complete UTF-8 sequence and unconditionally read c:byte(2..4). But Data.String.CodeUnits slices a String byte-wise (toCharArray = s...
X Description: The v6.1.1 toCharCode rewrite (#79) assumed every Char value is a complete UTF-8 sequence and unconditionally read c:byte(2..4). But Data.String.CodeUnits slices a String byte-wise (toCharArray = s...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/102
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[fork-ffi] enums: toCharCode crashes on a lone code-unit byte (regression in v6.1.1)","articleBody":"The v6.1.1 `toCharCode` rewrite (#79) assumed every `Char` value is a *complete* UTF-8 sequence and unconditionally read `c:byte(2..4)`. But `Data.String.CodeUnits` slices a String **byte-wise** (`toCharArray` = `s:sub(i,i)`, one byte each) and lets `Data.String.CodePoints` reassemble code points, so `toCharCode` is routinely called on a **single byte** that is the lead/continuation byte of a multibyte char. On such input `c:byte(2)` is `nil` → `attempt to perform arithmetic on a nil value`.\n\nReproduced via the StringCodePoints eval golden (CI), which crashed at runtime:\n`golden.lua: attempt to perform arithmetic on a nil value … in function 'toCharCode'`.\n\nShipped in package set `psc-0.15.15-20260615` (enums v6.1.1). Fix: length-guard the decode — only assemble the full code point when the whole sequence is present (`#c >= expected`), otherwise return the lead byte (the old byte-in/byte-out behavior the CodePoints layer relies on). The Char-literal decoding from #79 is preserved. Regression test adds lone-byte cases. Fixed in enums v6.1.2 / set `psc-0.15.15-20260615-2`.","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-06-15T13:24:13Z","url":"https://github.com/purescript-lua/purescript-lua/issues/102"}
| 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:92dd0cdc-fbfa-b7a1-1645-7cd343675e9c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C212:213839:7F866D:A6BA6E:6B00D945 |
| html-safe-nonce | c2798e5a0a7fa41860ebf12a1d1bce6022346a75116668012e6487685e17346f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMjEyOjIxMzgzOTo3Rjg2NkQ6QTZCQTZFOjZCMDBEOTQ1IiwidmlzaXRvcl9pZCI6Ijc0OTY5NzU3NzYxNDc4ODg0NTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bb96b2efbda4483d0314020298f7f4f6c3fe6bb4e7c556719c6e16102d3962f1 |
| hovercard-subject-tag | issue:4665483689 |
| 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/102/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dfff6f9506f1c13d12023c2b644029bf6b82ed78337151a11bd464c482dc963b/purescript-lua/purescript-lua/issues/102 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dfff6f9506f1c13d12023c2b644029bf6b82ed78337151a11bd464c482dc963b/purescript-lua/purescript-lua/issues/102 |
| og:image:alt | The v6.1.1 toCharCode rewrite (#79) assumed every Char value is a complete UTF-8 sequence and unconditionally read c:byte(2..4). But Data.String.CodeUnits slices a String byte-wise (toCharArray = s... |
| 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