Skip to content

[EE] Handle ArrayExpansion for 1D array with non-zero lower bounds#58915

Merged
tmat merged 1 commit intodotnet:mainfrom
r-ramesh:dev/ramram/fixArrayLowerBound
Jan 20, 2022
Merged

[EE] Handle ArrayExpansion for 1D array with non-zero lower bounds#58915
tmat merged 1 commit intodotnet:mainfrom
r-ramesh:dev/ramram/fixArrayLowerBound

Conversation

@r-ramesh
Copy link
Copy Markdown
Contributor

@r-ramesh r-ramesh commented Jan 18, 2022

Issue:

  • Evaluating + expanding Array myArray = Array.CreateInstance(typeof(int), new int[1] { 12 }, new int[1] { 1 }); while debugging crashes Visual Studio.
  • This is because Roslyn ends up passing an invalid index to VIL which throws an IndexOutOfRangeException and is expected. Roslyn should instead request the correct index.
  • Tracked by DevDiv Bug https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1456359

Changes:

  1. ArrayExpansion:

Issue:
- Evaluating + expanding `Array myArray = Array.CreateInstance(typeof(int), new int[1] { 12 }, new int[1] { 1 });` while debugging crashes Visual Studio.

Changes:
1. ArrayExpansion:
- Lower bounds correction wasn't being done for 1D arrays, so add it.
- This can't really be tested in C#/VB since Array.CreateInstance with 1D params can't be cast to a 1D array (see Remarks here: https://docs.microsoft.com/en-us/dotnet/api/system.array.createinstance#system-array-createinstance(system-type-system-int32()-system-int32())
- Corner case, will add tests on debugger side.
@ghost ghost added Community The pull request was submitted by a contributor who is not a Microsoft employee. Area-Interactive labels Jan 18, 2022
@r-ramesh
Copy link
Copy Markdown
Contributor Author

@cston @jinujoseph @tmat for review

@tmat tmat merged commit e70912b into dotnet:main Jan 20, 2022
@ghost ghost added this to the Next milestone Jan 20, 2022
@tmat
Copy link
Copy Markdown
Member

tmat commented Jan 20, 2022

@r-ramesh Thanks!

@tmat tmat modified the milestones: Next, 17.2 Jan 20, 2022
@r-ramesh r-ramesh deleted the dev/ramram/fixArrayLowerBound branch May 11, 2022 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Interactive Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants