about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-03-28 17:01:42 -0700
committerNiko Matsakis <niko@alum.mit.edu>2012-03-28 17:02:54 -0700
commitfe610f04d89ae30e7ad68b9b519aa8461cd8d0fb (patch)
tree3914cd6dea89d941424dfdb5c799f93309d4f96b
parent23f92ea3701d515ac617c4c9ad18d4b25ecd4675 (diff)
downloadrust-fe610f04d89ae30e7ad68b9b519aa8461cd8d0fb.tar.gz
rust-fe610f04d89ae30e7ad68b9b519aa8461cd8d0fb.zip
use fresh vars in place of _|_ when incorrect # of params supplied
-rw-r--r--src/rustc/middle/typeck.rs12
-rw-r--r--src/test/compile-fail/not-enough-arguments.rs12
2 files changed, 19 insertions, 5 deletions
diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs
index 7d89091d475..75add819e39 100644
--- a/src/rustc/middle/typeck.rs
+++ b/src/rustc/middle/typeck.rs
@@ -2362,11 +2362,13 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
                          } else {
                              "s were"
                          }]);
-            // HACK: build an arguments list with dummy arguments to
-            // check against
-            let dummy = {mode: ast::expl(ast::by_ref),
-                         ty: ty::mk_bot(fcx.ccx.tcx)};
-            arg_tys = vec::from_elem(supplied_arg_count, dummy);
+
+            // Just use fresh type variables for the types,
+            // since we don't know them.
+            arg_tys = vec::from_fn(supplied_arg_count) {|_i|
+                {mode: ast::expl(ast::by_ref),
+                 ty: next_ty_var(fcx)}
+            };
         }
 
         // Check the arguments.
diff --git a/src/test/compile-fail/not-enough-arguments.rs b/src/test/compile-fail/not-enough-arguments.rs
new file mode 100644
index 00000000000..2aeda5a7652
--- /dev/null
+++ b/src/test/compile-fail/not-enough-arguments.rs
@@ -0,0 +1,12 @@
+// Check that the only error msg we report is the
+// mismatch between the # of params, and not other
+// unrelated errors.
+
+fn foo(a: int, b: int, c: int, d:int) {
+  fail;
+}
+
+fn main() {
+  foo(1, 2, 3);
+  //!^ ERROR this function takes 4 parameters but 3
+}