Skip to content

Fix indexing in mapWithIndexArray and traverseArrayImpl#1

Closed
sarahnya wants to merge 1 commit into
purescript-lua:masterfrom
sarahnya:indexing-fix
Closed

Fix indexing in mapWithIndexArray and traverseArrayImpl#1
sarahnya wants to merge 1 commit into
purescript-lua:masterfrom
sarahnya:indexing-fix

Conversation

@sarahnya

Copy link
Copy Markdown

Description of the change

Changes are made such that lua arrays use the lua convention of 1 based indexing while purescript arrays use 0 based indexing.


Checklist:

  • Added the change to the changelog's "Unreleased" section with a reference to this PR (e.g. "- Made a change (#0000)")
  • Linked any existing issues or proposals that this pull request should close
  • Updated or added relevant documentation
  • Added a test for the contribution (if applicable)

Changes are made such that lua arrays use the lua convention of 1 based
indexing while purescript arrays use 0 based indexing.
Unisay added a commit that referenced this pull request Jun 14, 2026
Follows the merged traverse fix (#2 by @Renegatto). On top of it:

- Fix mapWithIndexArray: it passed the 1-based Lua loop index to f, but
  PureScript mapWithIndex is 0-based, so f received i instead of i-1
  (originally reported in #1 by @sarahnya).
- Add a focused regression suite (test-regression/) run by scripts/test:
  traverse over Maybe is length/order-preserving at every size (>3 hits
  the pivot/append branch, which needs the Array Semigroup fix shipped in
  prelude v7.2.2), traverse over the Array applicative, and 0-based
  mapWithIndex.
- Align tooling: purescript-overlay dev shell on Lua 5.1 (drops easy-ps /
  insecure nodejs), canonical nix CI replacing the bower workflow,
  fail-fast scripts, and bump the package set to psc-0.15.15-20260614
  (prelude v7.2.2). Supersedes the earlier normalization PR #3.

Closes #1
@Unisay

Unisay commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Thanks @sarahnya — both halves of this are now addressed. The traverseArrayImpl indexing was fixed more completely in #2 (which also fixes the broken table.concat array-append), and your mapWithIndexArray 0-based fix is carried in #4 with a regression test crediting this report. Closing as superseded.

@Unisay Unisay closed this Jun 14, 2026
Sign up for free to 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