Skip to content

Add failing test for Seq/Array atOrElse IndexOutOfBoundsException (issue #301)#305

Closed
adamw wants to merge 1 commit into
masterfrom
fix-seq-array-at-or-else-out-of-bounds
Closed

Add failing test for Seq/Array atOrElse IndexOutOfBoundsException (issue #301)#305
adamw wants to merge 1 commit into
masterfrom
fix-seq-array-at-or-else-out-of-bounds

Conversation

@adamw

@adamw adamw commented Jun 16, 2026

Copy link
Copy Markdown
Member

Addresses #301.

The atOrElse operator on Seq/Array currently throws IndexOutOfBoundsException when accessing a missing index instead of using the provided default value. This test demonstrates the expected behavior.

The test includes two cases: modifying an existing element at a valid index (current working behavior), and accessing a missing index with atOrElse without throwing (expected behavior that currently fails).

The actual fix implementation is pending.

Closes #301.

@adamw

adamw commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

The CI failure is a compilation error, not a test failure. The atOrElse method does not exist on List — the test file references it, but the implementation hasn't been added yet.


CI failure summary:

Compilation fails across all Scala 2.x targets on ModifySeqAtOrElseTest.scala. The test calls _.atOrElse(index, default) on List, but the method doesn't exist in the library yet — the PR adds only the failing test, not the implementation.

Specific errors (repeated for Scala 2.11, 2.12, 2.13):

ModifySeqAtOrElseTest.scala:10:18: value atOrElse is not a member of List[A3]
    modify(l1)(_.atOrElse(2, A3(A4(A5("d4")))).a4.a5.name).using(duplicate) should be(l1at2dup)

ModifySeqAtOrElseTest.scala:16:23: value atOrElse is not a member of List[A5]
    modify(items)(_.atOrElse(5, A5("default")).name).using(duplicate)

There is also a secondary error caused by the first: missing argument list for method duplicate (the type inference chain breaks once atOrElse is unknown).

Root cause: The atOrElse extension on Seq/Array focus paths has not been implemented. The test commit (426a6d3) intentionally adds a failing test — the fix (wiring atOrElse into the quicklens macro/path machinery) still needs to be written.

@adamw adamw closed this Jun 16, 2026
@adamw adamw deleted the fix-seq-array-at-or-else-out-of-bounds branch June 16, 2026 07:33
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.

Seq/Array atOrElse throws IndexOutOfBoundsException for missing indices instead of using default

1 participant