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.
This commit is contained in:
parent
776977b755
commit
c9a8bdee2f
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user