Skip to content

fix: restore the missing Data.Array.ST.clone - #4

Merged
Unisay merged 1 commit into
masterfrom
issue-267/st-clone
Jul 13, 2026
Merged

fix: restore the missing Data.Array.ST.clone#4
Unisay merged 1 commit into
masterfrom
issue-267/st-clone

Conversation

@Unisay

Copy link
Copy Markdown
Collaborator

Problem

Upstream purescript-arrays v7.3.0 exports Data.Array.ST.clone, backed by the cloneImpl :: STFn1 (STArray h a) h (STArray h a) foreign. The fork tracks the 7.3.0 sources but carried neither the export nor the foreign, so code written against the registry package failed to compile against the fork ("Unknown value clone"). Found by the upstream diff of the purescript-lua/purescript-lua#186 audit, where this was the only missing value export in arrays.

Change

  • src/Data/Array/ST.purs: restore clone/cloneImpl exactly as upstream declares them (export after thaw, declarations after thawImpl).
  • src/Data/Array/ST.lua: bind cloneImpl to the existing copyImpl, the same independent copy thawImpl/freezeImpl already use, per the STFn convention: a 1-ary entry that performs the copy directly.
  • test/regression/array_st.lua: the guard covers cloneImpl (copies, independent of the source). It was red against the old FFI (attempt to call field 'cloneImpl' (a nil value)) and is green after the fix.

Verification

scripts/test green (regression suites for ST and NonEmpty), luacheck --std lua51 --no-unused-args src/ clean, nix develop -c ./scripts/build links all seven modules. End-to-end check with a small program that thaws [1,2,3], clones it, and pokes the clone, built on set psc-0.15.15-20260713 with arrays overridden to this checkout: before the fix purs rejected it with "Unknown value clone"; with the fix it compiles and prints [1,2,3] then [99,2,3], so poking the clone leaves the source array intact.

Suggested release: patch (v7.4.3) plus a package-set bump.

Refs purescript-lua/purescript-lua#267.

Upstream purescript-arrays v7.3.0 exports clone, backed by the
cloneImpl :: STFn1 (STArray h a) h (STArray h a) foreign, but the fork
tracked the 7.3.0 sources with neither the export nor the foreign, so
code written against the registry package failed to compile against the
fork ("Unknown value clone"). Restore the declarations as upstream
states them and bind cloneImpl to the same independent copy the FFI
already uses for thawImpl/freezeImpl; the regression guard now covers
it.
Refs purescript-lua/purescript-lua#267.
@Unisay
Unisay marked this pull request as ready for review July 13, 2026 17:13
@Unisay
Unisay requested a review from CopilotJuly 13, 2026 17:13
@UnisayUnisay self-assigned this Jul 13, 2026

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores the missing Data.Array.ST.clone API in this PureScript→Lua arrays fork to match upstream purescript-arrays v7.3.0, fixing downstream compilation failures for code expecting Data.Array.ST.clone.

Changes:

  • Re-add clone and its cloneImpl foreign to Data.Array.ST, matching upstream signatures and export ordering.
  • Implement cloneImpl in Lua by reusing the existing copyImpl (same independent-copy path used by freezeImpl/thawImpl).
  • Add a Lua regression guard asserting cloneImpl produces an independent copy.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

FileDescription
src/Data/Array/ST.pursReintroduces clone export and foreign cloneImpl with STFn1 wiring via runSTFn1.
src/Data/Array/ST.luaExposes cloneImpl = (copyImpl) consistent with existing freezeImpl/thawImpl behavior and FFI export wrapping requirements.
test/regression/array_st.luaAdds regression coverage ensuring cloneImpl copies and is independent of the source table.
changelog.d/20260713_180352_st_clone.mdDocuments the restoration of Data.Array.ST.clone and its Lua backing implementation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Unisay
Unisay merged commit e7c3daf into masterJul 13, 2026
2 checks passed
@Unisay
Unisay deleted the issue-267/st-clone branch July 13, 2026 19:11
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Unisay