resolve type variables with no constraints to bot

This commit is contained in:
Niko Matsakis 2012-03-26 12:53:34 -07:00
parent f452973a7f
commit 76d0a13ae5
4 changed files with 20 additions and 10 deletions

View File

@ -707,7 +707,7 @@ fn rerr<T>(v: int) -> fres<T> {
fn resolve_var<T:copy to_str>(
vb: vals_and_bindings<T>, bot_guard: fn(T)->bool,
vid: int) -> fres<T> {
vid: int, unbound: fn() -> fres<T>) -> fres<T> {
let {root:_, bounds} = self.get(vb, vid as uint);
@ -724,16 +724,24 @@ fn resolve_var<T:copy to_str>(
{ ub:_, lb:some(t) } if !bot_guard(t) { ok(t) }
{ ub:some(t), lb:_ } { ok(t) }
{ ub:_, lb:some(t) } { ok(t) }
{ ub:none, lb:none } { self.rerr(vid) }
{ ub:none, lb:none } { unbound() }
}
}
fn resolve_ty_var(vid: int) -> fres<ty::t> {
ret self.resolve_var(self.vb, {|t| type_is_bot(t)}, vid);
ret self.resolve_var(
self.vb,
{|t| type_is_bot(t) },
vid,
{|| ok(ty::mk_bot(self.tcx)) });
}
fn resolve_region_var(rid: int) -> fres<ty::region> {
ret self.resolve_var(self.rb, {|_t| false}, rid);
ret self.resolve_var(
self.rb,
{|_t| false },
rid,
{|| err(rid) });
}
fn resolve_ty(typ: ty::t) -> fres<ty::t> {

View File

@ -1,2 +0,0 @@
// error-pattern:cannot determine a type
fn main() { let foo = []; }

View File

@ -0,0 +1,4 @@
fn main() {
// We will infer this to have the type vec[bot]
let _foo = [];
}

View File

@ -1,6 +1,6 @@
// Just a grab bag of stuff that you wouldn't want to actually write.
fn strange() -> bool { let _x: bool = ret true; }
fn strange() -> bool { let _x = ret true; }
fn funny() {
fn f(_x: ()) { }
@ -19,8 +19,8 @@ fn zombiejesus() {
do {
while (ret) {
if (ret) {
alt check (ret) {
1 {
alt (ret) {
_ {
if (ret) {
ret
} else {
@ -51,7 +51,7 @@ fn canttouchthis() -> uint {
pure fn p() -> bool { true }
let _a = (assert (true)) == (check (p()));
let _c = (check (p())) == ();
let _b: bool = (log(debug, 0) == (ret 0u));
let _b = (log(debug, 0) == (ret 0u));
}
fn angrydome() {