Title: [fork-ffi] arrays: unshiftAllImpl — Must prepend `as` to the front of `xs` (JS `xs.unshift.apply(xs,… · Issue #74 · purescript-lua/purescript-lua · GitHub
Open Graph Title: [fork-ffi] arrays: unshiftAllImpl — Must prepend `as` to the front of `xs` (JS `xs.unshift.apply(xs,… · Issue #74 · purescript-lua/purescript-lua
X Title: [fork-ffi] arrays: unshiftAllImpl — Must prepend `as` to the front of `xs` (JS `xs.unshift.apply(xs,… · Issue #74 · purescript-lua/purescript-lua
Description: Package: purescript-lua-arrays File: src/Data/Array/ST.lua Function: unshiftAllImpl Class: semantics Severity: high Must prepend as to the front of xs (JS xs.unshift.apply(xs, as)), shifting existing elements right and growing the array ...
Open Graph Description: Package: purescript-lua-arrays File: src/Data/Array/ST.lua Function: unshiftAllImpl Class: semantics Severity: high Must prepend as to the front of xs (JS xs.unshift.apply(xs, as)), shifting existi...
X Description: Package: purescript-lua-arrays File: src/Data/Array/ST.lua Function: unshiftAllImpl Class: semantics Severity: high Must prepend as to the front of xs (JS xs.unshift.apply(xs, as)), shifting existi...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/74
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[fork-ffi] arrays: unshiftAllImpl — Must prepend `as` to the front of `xs` (JS `xs.unshift.apply(xs,…","articleBody":"**Package:** purescript-lua-arrays \n**File:** `src/Data/Array/ST.lua` \n**Function:** `unshiftAllImpl` \n**Class:** semantics **Severity:** high\n\nMust prepend `as` to the front of `xs` (JS `xs.unshift.apply(xs, as)`), shifting existing elements right and growing the array by #as. Instead it does `move(as, 1, #as, 1, xs)`, which copies `as` over the first #as slots of `xs`, overwriting existing elements and leaving the rest in place -- it neither shifts nor grows. Confirmed under Lua 5.1: unshiftAllImpl({1,2}, {3,4,5}) produced {1,2,5} (length 3) instead of {1,2,3,4,5} (length 5), and returned 3 instead of 5.\n\n**Current (Lua):**\n```lua\nunshiftAllImpl = (function(as, xs)\n local r = move(as, 1, #as, 1, xs)\n return #r\nend)\n```\n\n**Expected:** Prepend all of `as`: xs becomes as ++ old-xs, and the new length (#as + old #xs) is returned. unshiftAllImpl({1,2}, {3,4,5}) must mutate xs to {1,2,3,4,5} and return 5.\n\n**Proposed fix:**\n```lua\nShift the existing tail right by #as first, then copy `as` into the front:\n unshiftAllImpl = (function(as, xs)\n local na, nx = #as, #xs\n for i = nx, 1, -1 do xs[i + na] = xs[i] end\n for i = 1, na do xs[i] = as[i] end\n return nx + na\n end)\nVerified under Lua 5.1: yields {1,2,3,4,5}, returns 5.\n```\n\n_Found by the FFI audit; reproduced under Lua 5.1._","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-06-15T11:23:52Z","url":"https://github.com/purescript-lua/purescript-lua/issues/74"}
| 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:e3846831-efa7-1c48-6a66-468400839bf5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C872:2454CC:630D15:7FED4B:6B00DFAE |
| html-safe-nonce | b91eedea653b4dfd971d2ae5f6420f33598cf451f2140ef4219021fb35425ab2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODcyOjI0NTRDQzo2MzBEMTU6N0ZFRDRCOjZCMDBERkFFIiwidmlzaXRvcl9pZCI6IjUwODk2NTQzOTM1MTU1OTc3NDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fb9d67888c45e3847b8d769b393fe21a137c385f3e9ab7bfd64cfbf5781f7979 |
| hovercard-subject-tag | issue:4664606301 |
| 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/74/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a8ffba588154338b11ef1747499e1326c02bf61da60b8fd30ca536f97b158448/purescript-lua/purescript-lua/issues/74 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a8ffba588154338b11ef1747499e1326c02bf61da60b8fd30ca536f97b158448/purescript-lua/purescript-lua/issues/74 |
| og:image:alt | Package: purescript-lua-arrays File: src/Data/Array/ST.lua Function: unshiftAllImpl Class: semantics Severity: high Must prepend as to the front of xs (JS xs.unshift.apply(xs, as)), shifting existi... |
| 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