@@ -47,7 +47,7 @@ private Expression MakeSubtractionExpression(IExpressionParentEntity parent, int
4747 return new Expression ( info ) ;
4848 }
4949
50- private void MakeLengthPropertyCall ( TextWriter trapFile , IPropertySymbol lengthPropertySymbol , IExpressionParentEntity parent , int child )
50+ private Expression MakeLengthPropertyCall ( TextWriter trapFile , IPropertySymbol lengthPropertySymbol , IExpressionParentEntity parent , int child )
5151 {
5252 var lengthInfo = new ExpressionInfo (
5353 Context ,
@@ -63,6 +63,7 @@ private void MakeLengthPropertyCall(TextWriter trapFile, IPropertySymbol lengthP
6363
6464 var lengthProp = Property . Create ( Context , lengthPropertySymbol ) ;
6565 trapFile . expr_access ( length , lengthProp ) ;
66+ return length ;
6667 }
6768
6869 private Expression CreateFromIndexExpression ( TextWriter trapFile , IPropertySymbol lengthPropertySymbol , IExpressionParentEntity parent , int child , PrefixUnaryExpressionSyntax index )
@@ -137,6 +138,7 @@ private void PopulateSlice(TextWriter trapFile, IPropertySymbol lengthPropertySy
137138 // 1. s[a..b] -> s.Slice(a, b - a)
138139 // 2. s[..b] -> s.Slice(0, b)
139140 // 3. s[a..] -> s.Slice(a, s.Length - a)
141+ // 4. s[..] -> s.Slice(0, s.Length)
140142 // Furthermore, note that uses of index expressions (e.g. s[2..^1]) within the range
141143 // get translated to length - index, so we need to handle this as well.
142144 switch ( range . LeftOperand , range . RightOperand )
@@ -168,6 +170,13 @@ private void PopulateSlice(TextWriter trapFile, IPropertySymbol lengthPropertySy
168170 SetExprArgument ( trapFile , left , right ) ;
169171 break ;
170172 }
173+ case ( null , null ) :
174+ {
175+ var left = Literal . CreateGenerated ( Context , this , 0 , Context . Compilation . GetSpecialType ( SpecialType . System_Int32 ) , 0 , Location ) ;
176+ var right = MakeLengthPropertyCall ( trapFile , lengthPropertySymbol , this , 1 ) ;
177+ SetExprArgument ( trapFile , left , right ) ;
178+ break ;
179+ }
171180 }
172181
173182 trapFile . expr_call ( this , Method . Create ( Context , slice ) ) ;
0 commit comments