-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array index from end in ValueTuple assignment throws IndexOutOfRangeException #58472
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Yup. I repro this, and it's super odd. @jcouv ? |
Seems like there are two issues at play. Roslyn is emitting invalid IL for the second assignment:
The |
repros for: M(new int[1]);
void M<T>(T[] a)
{
(int v, a[^1]) = (default, default);
} Does not repro for: M(new int[1]);
void M(int[] a)
{
(int v, a[^1]) = (default, default);
} |
Doesn't reproduce in |
Description
Assignment from tuple destructuring into a FromEnd index of a generic array throws IndexOutOfRangeException. It looks like
stelem
is called with the Index's raw value, instead of a computed value from the array length.Reproduction Steps
Expected behavior
Assignment succeeds
Actual behavior
IndexOutOfRangeException
Regression?
No response
Known Workarounds
No response
Configuration
.NET 6.0.101
Other information
No response
The text was updated successfully, but these errors were encountered: