File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -476,10 +476,26 @@ public override void VisitArrayCreationExpression(ArrayCreationExpressionSyntax
476476 }
477477 else
478478 {
479+ SymbolDefinition capturedRank ;
480+
479481 using ( ExpressionCaptureScope rankCapture = new ExpressionCaptureScope ( visitorContext , null ) )
480482 {
481483 Visit ( node . Type . RankSpecifiers [ 0 ] ) ;
482- arrayRankSymbol = rankCapture . ExecuteGet ( ) ;
484+ capturedRank = rankCapture . ExecuteGet ( ) ;
485+ }
486+
487+ if ( capturedRank . symbolCsType == typeof ( int ) )
488+ {
489+ arrayRankSymbol = capturedRank ;
490+ }
491+ else
492+ {
493+ using ( ExpressionCaptureScope convertScope = new ExpressionCaptureScope ( visitorContext , null ) )
494+ {
495+ arrayRankSymbol = visitorContext . topTable . CreateUnnamedSymbol ( typeof ( int ) , SymbolDeclTypeFlags . Internal ) ;
496+ convertScope . SetToLocalSymbol ( arrayRankSymbol ) ;
497+ convertScope . ExecuteSet ( capturedRank , true ) ;
498+ }
483499 }
484500 }
485501
Original file line number Diff line number Diff line change @@ -86,6 +86,19 @@ public void ExecuteTests()
8686
8787 tester . TestAssertion ( "Unity VideoPlayer array" , unityVideoPlayerArray [ 0 ] != null && unityVideoPlayerArray [ 1 ] != null ) ;
8888 tester . TestAssertion ( "Base VRCStation array" , baseVideoPlayerArray [ 0 ] != null && baseVideoPlayerArray [ 1 ] != null ) ;
89+
90+ // Test implicit array rank conversions
91+ float [ ] myFloatArr = new float [ 20U ] ;
92+ tester . TestAssertion ( "Array size implicit conversion 1" , myFloatArr . Length == 20 ) ;
93+
94+ uint arrSize = 4 ;
95+ myFloatArr = new float [ arrSize ] ;
96+ tester . TestAssertion ( "Array size implicit conversion 2" , myFloatArr . Length == 4 ) ;
97+
98+ byte arrSize2 = 30 ;
99+ myFloatArr = new float [ arrSize2 ] ;
100+
101+ tester . TestAssertion ( "Array size implicit conversion 3" , myFloatArr . Length == 30 ) ;
89102 }
90103 }
91104}
You can’t perform that action at this time.
0 commit comments