diff options
| author | Patrick Walton <[email protected]> | 2011-03-18 17:45:11 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-03-18 17:45:47 -0700 |
| commit | 9c0c0af1b225bc26c0b73434221efe6ffbb373c3 (patch) | |
| tree | 0cf4afe8ee25e955a39e4f3a0586b1bbaeb2c0f6 /src/comp | |
| parent | Add rules for stage0/rustc to Makefile.in. (diff) | |
| download | rust-9c0c0af1b225bc26c0b73434221efe6ffbb373c3.tar.xz rust-9c0c0af1b225bc26c0b73434221efe6ffbb373c3.zip | |
rustc: Fix inference for auto slots (forgot to stage changes before)
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/typeck.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 52dc2eed..a060cbde 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -924,7 +924,9 @@ fn collect_item_types(session.session sess, @ast.crate crate) fn unify(&@fn_ctxt fcx, @ty.t expected, @ty.t actual) -> ty.unify_result { obj unify_handler(@fn_ctxt fcx) { fn resolve_local(ast.def_id id) -> @ty.t { - check (fcx.locals.contains_key(id)); + if (!fcx.locals.contains_key(id)) { + ret next_ty_var(fcx.ccx); + } ret fcx.locals.get(id); } fn record_local(ast.def_id id, @ty.t t) { @@ -2377,20 +2379,17 @@ fn check_decl_local(&@fn_ctxt fcx, &@ast.decl decl) -> @ast.decl { alt (decl.node) { case (ast.decl_local(?local)) { - auto local_ty; alt (local.ty) { case (none[@ast.ty]) { - // Auto slot. Assign a ty_var. - local_ty = next_ty_var(fcx.ccx); + // Auto slot. Do nothing for now. } case (some[@ast.ty](?ast_ty)) { - local_ty = ast_ty_to_ty_crate(fcx.ccx, ast_ty); + auto local_ty = ast_ty_to_ty_crate(fcx.ccx, ast_ty); + fcx.locals.insert(local.id, local_ty); } } - fcx.locals.insert(local.id, local_ty); - auto rhs_ty = local_ty; auto init = local.init; alt (local.init) { case (some[@ast.expr](?expr)) { |