Fixed IndexExpressions not computing slices for calls.
authorDavid Anderson <dvander@alliedmods.net>
Sun Aug 05 14:19:19 2012 -0700 (2012-08-05)
changeset 1663ac2a36a7a0c
parent 165 b67697fba413
child 167 cf82769eb136
Fixed IndexExpressions not computing slices for calls.
src/SemanticAnalysis.cpp
     1.1 --- a/src/SemanticAnalysis.cpp	Sun Aug 05 14:19:05 2012 -0700
     1.2 +++ b/src/SemanticAnalysis.cpp	Sun Aug 05 14:19:19 2012 -0700
     1.3 @@ -1133,6 +1133,16 @@
     1.4              mustComputeReference = !given->isReference() && !given->isArray();
     1.5          } else {
     1.6              Local<Type> actual(zone_, type->parameterAt(i));
     1.7 +
     1.8 +            if (expression->isIndexExpression() && actual->isArray()) {
     1.9 +                // We special case the ability to pass x[y] into x[], which
    1.10 +                // creates an array slice. We only do this if we know the
    1.11 +                // assignment would otherwise not type-check.
    1.12 +                IndexExpression *index = expression->toIndexExpression();
    1.13 +                if (index->left()->type()->levels() == actual->levels())
    1.14 +                    given = index->left()->type();
    1.15 +            }
    1.16 +
    1.17              if (!typeCheckParameter(expression, given, actual))
    1.18                  return;
    1.19              mustComputeReference = actual->isReference() && !given->isReference();