New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect inference for default methods on generic traits #4099

Closed
brson opened this Issue Dec 3, 2012 · 6 comments

Comments

Projects
None yet
3 participants
@brson
Contributor

brson commented Dec 3, 2012

trait A<T> {
    fn g(x: T) -> T { move x }
}

impl int: A<int> { }

fn main () {
    assert 0i.g(2i) == 2i;
}
/home/brian/dev/rust/src/test/run-pass/trait-default-method-bound-subst2.rs:8:16: 8:18 error: mismatched types: expected `'a` but found `int` (expected type parameter but found int)
/home/brian/dev/rust/src/test/run-pass/trait-default-method-bound-subst2.rs:8     assert 0i.g(2i) == 2i;
                                                                                              ^~
/home/brian/dev/rust/src/test/run-pass/trait-default-method-bound-subst2.rs:8:11: 8:25 error: binary operation == cannot be applied to type `'a`
/home/brian/dev/rust/src/test/run-pass/trait-default-method-bound-subst2.rs:8     assert 0i.g(2i) == 2i;
                                                                                         ^~~~~~~~~~~~~~
/home/brian/dev/rust/src/test/run-pass/trait-default-method-bound-subst2.rs:8:11: 8:25 error: mismatched types: expected `bool` but found `'a` (expected bool but found type parameter)
/home/brian/dev/rust/src/test/run-pass/trait-default-method-bound-subst2.rs:8     assert 0i.g(2i) == 2i;
                                                                                         ^~~~~~~~~~~~~~
error: aborting due to 3 previous errors


@catamorphism

This comment has been minimized.

Show comment
Hide comment
@catamorphism

catamorphism Feb 21, 2013

Contributor

Reproduced as of eed2ca6

Contributor

catamorphism commented Feb 21, 2013

Reproduced as of eed2ca6

@ghost ghost assigned catamorphism Feb 21, 2013

@catamorphism

This comment has been minimized.

Show comment
Hide comment
@catamorphism

catamorphism May 18, 2013

Contributor

I noticed a comment in typeck::check::method::push_candidates_from_provided_methods that's just using an empty substitution all the time when checking default methods. This may be related; I annotated it with this issue number.

Contributor

catamorphism commented May 18, 2013

I noticed a comment in typeck::check::method::push_candidates_from_provided_methods that's just using an empty substitution all the time when checking default methods. This may be related; I annotated it with this issue number.

@msullivan

This comment has been minimized.

Show comment
Hide comment
@msullivan

msullivan Jun 7, 2013

Contributor

Updated version

#[allow(default_methods)];

trait A<T> {
    fn g(&self, x: T) -> T { x }
}

impl A<int> for int { }

fn main () {
    assert!(0i.g(2i) == 2i);
}

fails with an ICE in trans. Probably is the same bug as #4102.

Contributor

msullivan commented Jun 7, 2013

Updated version

#[allow(default_methods)];

trait A<T> {
    fn g(&self, x: T) -> T { x }
}

impl A<int> for int { }

fn main () {
    assert!(0i.g(2i) == 2i);
}

fails with an ICE in trans. Probably is the same bug as #4102.

@msullivan

This comment has been minimized.

Show comment
Hide comment
@msullivan

msullivan Jun 7, 2013

Contributor

push_candidates_from_provided_methods doesn't actually seem to get used... I am confused now.

Contributor

msullivan commented Jun 7, 2013

push_candidates_from_provided_methods doesn't actually seem to get used... I am confused now.

@msullivan

This comment has been minimized.

Show comment
Hide comment
@msullivan

msullivan Jun 12, 2013

Contributor

Bug was in trans. push_candidates_from_provided_methods is (it appears) dead code. The code path that calls it never gets exercised, it seems?

Contributor

msullivan commented Jun 12, 2013

Bug was in trans. push_candidates_from_provided_methods is (it appears) dead code. The code path that calls it never gets exercised, it seems?

@msullivan msullivan closed this in 36e3d64 Jun 13, 2013

@msullivan

This comment has been minimized.

Show comment
Hide comment
@msullivan

msullivan Jun 15, 2013

Contributor

Marking that this was part of #2794 for tracking purposes.

Contributor

msullivan commented Jun 15, 2013

Marking that this was part of #2794 for tracking purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment