Skip to content

Commit 4eb52f6

Browse files
committed
do not fail if iface/impl method have different number of parameters
1 parent a7641e9 commit 4eb52f6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/comp/middle/typeck.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,13 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span, impl_m: ty::method,
620620
tcx.sess.span_err(sp, "method `" + if_m.ident +
621621
"` has an incompatible set of type parameters");
622622
ty::mk_fn(tcx, impl_m.fty)
623+
} else if vec::len(impl_m.fty.inputs) != vec::len(if_m.fty.inputs) {
624+
tcx.sess.span_err(sp,#fmt["method `%s`` has %u parameters \
625+
but the iface has %u",
626+
if_m.ident,
627+
vec::len(impl_m.fty.inputs),
628+
vec::len(if_m.fty.inputs)]);
629+
ty::mk_fn(tcx, impl_m.fty)
623630
} else {
624631
let auto_modes = vec::map2(impl_m.fty.inputs, if_m.fty.inputs, {|i, f|
625632
alt ty::get(f.ty).struct {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
iface foo {
2+
fn bar(x: uint) -> self;
3+
}
4+
impl of foo for int {
5+
fn bar() -> int {
6+
self
7+
}
8+
}
9+
10+
fn main() {
11+
}

0 commit comments

Comments
 (0)