Skip to content

[Repo Assist] [Dart] Fix Array.compareWith comparing lengths before elements#4460

Merged
dbrattli merged 6 commits intomainfrom
repo-assist/fix-dart-array-compareWith-2961-ec3221903852042e
Apr 3, 2026
Merged

[Repo Assist] [Dart] Fix Array.compareWith comparing lengths before elements#4460
dbrattli merged 6 commits intomainfrom
repo-assist/fix-dart-array-compareWith-2961-ec3221903852042e

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Fixes #2961Array.compareWith in the Dart target compared array lengths first, then elements. This produces wrong results for arrays that share a common prefix but differ in element values.

Root Cause

src/fable-library-dart/Array.fs had the comparison logic inverted:

// BEFORE (wrong — length-first)
if length1 > length2 then 1
elif length1 < length2 then -1
else
    while i < length1 && result = 0 do
        result <- comparer array1[i] array2[i]
        i <- i + 1
    result

So Array.compareWith compare [|1;3|] [|1;2;3|] returned -1 (shorter array is less) instead of 1 (1=1, then 3>2).

The .NET spec and all other fixed targets (JS/TS, Rust, Python) compare elements first, then use length as a tiebreaker.

Fix

Restructure to compare elements first over the minimum-length prefix, then use length as tiebreaker:

// AFTER (correct — element-first)
let minLength = if length1 < length2 then length1 else length2
while i < minLength && result = 0 do
    result <- comparer array1[i] array2[i]
    i <- i + 1
if result <> 0 then result
elif length1 > length2 then 1
elif length1 < length2 then -1
else 0

Also uncomments the Array.compareWith works test in tests/Dart/src/ArrayTests.fs that was already written but disabled due to this bug.

Test Plan

  • Uncommented test verifies Array.compareWith compare [|1;3|] [|1;2;3|] returns 1
  • CI will run ./build.sh test dart

Closes #2961

🤖 Generated with Repo Assist

Note

🔒 Integrity filtering filtered 82 items

Integrity filtering activated and filtered the following items during workflow execution.
This happens when a tool call accesses a resource that does not meet the required integrity or secrecy level of the workflow.

  • issue:[Repo Assist] Monthly Activity 2026-03 #4407 (issue_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4393 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4220 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4166 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4143 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4104 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4044 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4038 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #3290 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #2279 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #2154 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • issue:[Feature] Array2D operations #1764 (list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • issue:DateTime.ParseExact breaks REPL #2003 (list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • issue:Is there a way to get attributes on a union case? #2026 (list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • issue:Reflection for classes #2027 (list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • issue:StackOverflowException when compiling large match expression #2039 (list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • ... and 66 more items

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added automation Automated changes repo-assist Created by Repo Assist labels Mar 29, 2026
@dbrattli dbrattli marked this pull request as ready for review March 29, 2026 19:43
@dbrattli dbrattli merged commit e07316a into main Apr 3, 2026
23 checks passed
@dbrattli dbrattli deleted the repo-assist/fix-dart-array-compareWith-2961-ec3221903852042e branch April 3, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation Automated changes repo-assist Created by Repo Assist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Array.compareWith issue

1 participant