Skip to content

Default methods seem not to be able to call self yet #3683

Closed
@andymatuschak

Description

@andymatuschak

I'm guessing this is a consequence of #2794 not being done yet, but the folks in #rust told me to file it anyway:

This code sample:

trait Foo {
    fn a() -> int;
    fn b() -> int {
        self.a() + 2
    }
}

impl int: Foo {
    fn a() -> int {
        3
    }
}

fn main() {
    io::println(int::str(3.b()));
}

Generates this error:

4:8: 4:12 error: internal compiler error: self method call

With Rust built from f96a2a2 running on Mac OS 10.8.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions