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

improved diagnostics message when swapping array elements #597

Merged
merged 1 commit into from
Jun 13, 2022

Conversation

filipw
Copy link
Contributor

@filipw filipw commented Jun 12, 2022

At the moment it is easy to supply out of bounds indices when using array Swapped(...).

For example:

let arr = [1, 2, 3];
let swapped = LocalSwapped(0, 4, arr);

produces, on a default simulator:

Unhandled exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

This PR adds an extra bounds check, similar to what is already done elsewhere to convert the error message to a more helpful

Unhandled exception: Microsoft.Quantum.Simulation.Core.ExecutionFailException: Second index is out of bounds

Copy link
Member

@msoeken msoeken left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution @filipw

@msoeken
Copy link
Member

msoeken commented Jun 13, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@msoeken msoeken merged commit d46f8b8 into microsoft:main Jun 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants