diff -r 0c588a96837c -r 0cde1379b29f src/compiler/SemanticAnalysis.cpp --- a/src/compiler/SemanticAnalysis.cpp Mon Nov 19 02:12:13 2012 -0800 +++ b/src/compiler/SemanticAnalysis.cpp Thu Dec 20 00:59:38 2012 -0800 @@ -516,16 +516,23 @@ } } - // When we start overloading, coercion will have to happen later. - arg = coerce(arg, actual, Coerce_Arg); - if (!arg) - return; + if (actual->isReference()) { + // If the actual is a reference, the coercion rules are much + // stricter; the contained types must be identical. + // :TODO: make this not an assert + assert(ReferenceType::cast(actual)->contained() == arg->type()); + } else { + // When we start overloading, coercion will have to happen later. + arg = coerce(arg, actual, Coerce_Arg); + if (!arg) + return; + } mustComputeReference = actual->isReference() && !given->isReference(); } - // :TODO: handle mustComputeReference - assert(!mustComputeReference); + if (mustComputeReference) + arg = new (pool_) HToRef(arg->node(), arg->type(), arg); if (!args->append(arg)) return; @@ -640,6 +647,7 @@ return l; } + // :TODO: remove assert(l == r); return left->type(); @@ -741,8 +749,6 @@ return NULL; return hir; } - - assert(from == to); return hir; }