Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit d46f8b8

Browse files
authored
improve diagnostics message when swapping array elements (#597)
1 parent 5f9ba1c commit d46f8b8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Standard/src/Arrays/Arrays.qs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@ namespace Microsoft.Quantum.Arrays {
462462
/// Swapped(1, 3, [0, 1, 2, 3, 4]);
463463
/// ```
464464
function Swapped<'T>(firstIndex : Int, secondIndex : Int, arr : 'T[]) : 'T[] {
465+
Fact(firstIndex >= 0 and firstIndex < Length(arr), "First index is out of bounds");
466+
Fact(secondIndex >= 0 and secondIndex < Length(arr), "Second index is out of bounds");
465467
return arr
466468
w/ firstIndex <- arr[secondIndex]
467469
w/ secondIndex <- arr[firstIndex];

0 commit comments

Comments
 (0)