From 9427864f332318e1effaebac064af8d31d7dbf3e Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 11 Jul 2011 15:02:50 -0700 Subject: [PATCH] Unify the rhs and lhs types in a send Closes #662. One-line fixes are always the best :-D --- src/comp/middle/typeck.rs | 1 + src/test/run-pass/send-type-inference.rs | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 src/test/run-pass/send-type-inference.rs diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index e0cf926141e3..00b92cac5a05 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -1877,6 +1877,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) { fcx.ccx.tcx.sess.span_fatal(expr.span,s); } } + demand::simple(fcx, expr.span, chan_t, lhs_t); write::ty_only_fixup(fcx, id, chan_t); } case (ast::expr_recv(?lhs, ?rhs)) { diff --git a/src/test/run-pass/send-type-inference.rs b/src/test/run-pass/send-type-inference.rs new file mode 100644 index 000000000000..bd5b4afb80ba --- /dev/null +++ b/src/test/run-pass/send-type-inference.rs @@ -0,0 +1,10 @@ +// xfail-stage0 +// tests that ctrl's type gets inferred properly +type command[K, V] = rec(K key, V val); + +fn cache_server[K, V] (chan[chan[command[K,V]]] c) { + auto ctrl = port(); + c <| chan(ctrl); +} +fn main() { +} \ No newline at end of file