From c9a8bdee2f777671a30f93339016fae044b1a081 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 23 May 2011 19:44:04 -0700 Subject: [PATCH] Improve error message for ambiguous polymorphic types If a type still contains free type variables after typechecking (for example, as with "auto foo = []", the result was an assertion failure in typeck. Made it a human-readable error message instead. --- src/comp/middle/typeck.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 41fe38403f0..fd02f76d816 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -1570,6 +1570,11 @@ mod writeback { } } + if (ty::type_contains_vars(fcx.ccx.tcx, local_ty)) { + fcx.ccx.tcx.sess.span_err(sp, + "Ambiguous type " + ty_to_str(fcx.ccx.tcx, local_ty) + + "\n(Try adding more type annotations.)"); + } write::ty_only(fcx.ccx.tcx, local.ann.id, local_ty); }