diff -r 23627f8bc421 -r 8aa89dd41e25 jitcraft/SemanticAnalysis.cpp --- a/jitcraft/SemanticAnalysis.cpp Sat Jun 30 22:45:25 2012 -0700 +++ b/jitcraft/SemanticAnalysis.cpp Sat Jun 30 23:40:17 2012 -0700 @@ -395,6 +395,8 @@ assert(node->arguments()->size() == type->parameters()->length()); for (unsigned i = 0; i < node->arguments()->size(); i++) { + // Note: we don't compute references unless the callee needs a + // reference type. Expression *expression = node->arguments()->at(i); expression->accept(this); @@ -402,6 +404,12 @@ if (!given) return; + // If it's an IndexExpression, we special case the ability to compute + // a reference. Maybe we should compute actual Ref types for + // IndexExpression? + if (expression->isIndexExpression()) + given = given->contained(); + Type *actual = Type::cast(type->parameters()->at(i)); assert(TypeCheckParameter(given, actual));