Skip to content

Commit fe610f0

Browse files
committed
use fresh vars in place of _|_ when incorrect # of params supplied
1 parent 23f92ea commit fe610f0

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/rustc/middle/typeck.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,11 +2362,13 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
23622362
} else {
23632363
"s were"
23642364
}]);
2365-
// HACK: build an arguments list with dummy arguments to
2366-
// check against
2367-
let dummy = {mode: ast::expl(ast::by_ref),
2368-
ty: ty::mk_bot(fcx.ccx.tcx)};
2369-
arg_tys = vec::from_elem(supplied_arg_count, dummy);
2365+
2366+
// Just use fresh type variables for the types,
2367+
// since we don't know them.
2368+
arg_tys = vec::from_fn(supplied_arg_count) {|_i|
2369+
{mode: ast::expl(ast::by_ref),
2370+
ty: next_ty_var(fcx)}
2371+
};
23702372
}
23712373

23722374
// Check the arguments.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Check that the only error msg we report is the
2+
// mismatch between the # of params, and not other
3+
// unrelated errors.
4+
5+
fn foo(a: int, b: int, c: int, d:int) {
6+
fail;
7+
}
8+
9+
fn main() {
10+
foo(1, 2, 3);
11+
//!^ ERROR this function takes 4 parameters but 3
12+
}

0 commit comments

Comments
 (0)