Skip to content

[Python] Fix missing Array module implementations and tests#4520

Merged
ncave merged 5 commits intofable-compiler:mainfrom
ncave:python
Apr 10, 2026
Merged

[Python] Fix missing Array module implementations and tests#4520
ncave merged 5 commits intofable-compiler:mainfrom
ncave:python

Conversation

@ncave
Copy link
Copy Markdown
Collaborator

@ncave ncave commented Apr 9, 2026

  • [Beam] Fix List.Cons call replacement and test
  • [Beam/Dart/Python/TypeScript] Fix Array.Equals to use reference equality instead of structural equality
  • [Dart/Python/TypeScript/Rust] Fix Seq.foldBack2 for sequences with different lengths
  • [Python] Fix missing Array module implementations and tests

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Fable compiler replacements and runtime libraries to close gaps in Array/Seq behavior across targets (notably Python) and aligns tests accordingly, including fixes for Array.Equals reference equality and Seq.foldBack2 on uneven sequences.

Changes:

  • Fix Seq.foldBack2 to fold over the shorter sequence (TS/Dart/Python/Rust libraries) and update tests to cover uneven inputs.
  • Change Array.Equals/Object.Equals lowering to use reference equality for arrays (Dart/Python/TS compiler transforms) and add tests asserting the expected behavior.
  • Add missing Python Array runtime implementations (e.g., fold2, exists2, for_all2, iterate2, unzip3, zip3, all_pairs, descending sorts, where, exactly_one) plus expanded test coverage; also add Beam List.Cons replacement and tests.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Rust/tests/src/SeqTests.fs Adjust Seq length tests and cover uneven fold2/foldBack2 inputs.
tests/Rust/tests/src/HashSetTests.fs Rename helper to hashSet and clean up variable naming in tests/comments.
tests/Python/TestSeq.fs Expand Seq tests (length variants, equality/Equals, fold2/foldBack2, permute, replicate).
tests/Python/TestHashSet.fs Rename helper to hashSet and improve local variable naming.
tests/Python/TestArray.fs Add extensive Array behavior tests (equality vs Equals, indexing, ConvertAll, distinct*, exists2, where, fold2, iter2/iteri*, sorting desc, unzip3/zip3, allPairs, exactlyOne/tryExactlyOne).
tests/Js/Main/SeqTests.fs Expand Seq tests (length variants, fold2/foldBack2, sortWith).
tests/Js/Main/HashSetTests.fs Rename helper to hashSet and improve local variable naming.
tests/Js/Main/ArrayTests.fs Add array equality/Equals/comparison/indexing tests and more Array API coverage.
tests/Dart/src/SeqTests.fs Expand Seq tests (length variants, fold2/foldBack2, sortWith).
tests/Dart/src/HashSetTests.fs Improve local variable naming in tests/comments.
tests/Dart/src/ArrayTests.fs Add array equality/Equals/comparison/indexing tests and enable Array.splitAt test.
tests/Beam/SeqTests.fs Expand Seq length tests and cover uneven fold2/foldBack2 inputs.
tests/Beam/ListTests.fs Add tests for List.empty and List.Cons.
src/Fable.Transforms/Replacements.fs For TS/JS transforms, make Object.Equals use reference equality when the receiver is an array.
src/Fable.Transforms/Python/Replacements.fs Make array Equals use strict reference equality; add ConvertAll lowering for Python.
src/Fable.Transforms/Dart/Replacements.fs Make Object.Equals use reference equality when the receiver is an array (Dart).
src/Fable.Transforms/Beam/Replacements.fs Implement List.Cons replacement for Beam.
src/Fable.Compiler/CHANGELOG.md Document the fixes in compiler changelog.
src/Fable.Cli/CHANGELOG.md Document the fixes in CLI changelog.
src/fable-library-ts/Seq.fs Fix Seq.foldBack2 to fold to the shorter length.
src/fable-library-rust/src/Seq.fs Fix Seq.foldBack2 to fold to the shorter length.
src/fable-library-py/src/array.rs Add missing Python Array module functions and register them.
src/fable-library-py/fable_library/Seq.fs Fix Seq.foldBack2 to fold to the shorter length.
src/fable-library-py/fable_library/core/array.pyi Extend Python typing stubs for newly added Array APIs.
src/fable-library-py/fable_library/array_.py Re-export expanded Array APIs from the Python core module.
src/fable-library-dart/Seq.fs Fix Seq.foldBack2 to fold to the shorter length.

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.


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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.


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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


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

Copy link
Copy Markdown
Collaborator

@dbrattli dbrattli left a comment

Choose a reason for hiding this comment

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

Added a few comments, but looks really great. Thanks for fixing ❤️

@ncave ncave merged commit 4a1edb3 into fable-compiler:main Apr 10, 2026
49 checks passed
@ncave ncave deleted the python branch April 10, 2026 07:00
@dbrattli
Copy link
Copy Markdown
Collaborator

Thanks for merging @ncave. Python now has more than 2300 unit-tests and Beam more than 2400. That is 200 more for each of them is just 2 weeks 😊 ... quickly approaching Fable JS v4 quality (2500) 😲

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.

3 participants