Skip to content

unhelpful error message for missing (first) self param on traiit method #7575

Closed
@jbclements

Description

@jbclements

This code:

trait CtxtFn{
    pub fn f9(uint) -> uint;
}

pub fn use_ctxtfn<T : CtxtFn>(cf: T) -> uint {
    cf.f9(342)
}

...signals the error message:

error: type `T` does not implement any method in scope named `f9`

...which is kind of crazy, because T is bounded by CtxtFn, and I can see the definition of f9.
<before reading on: can you see the problem?>

I tore my hair out for quite a while before realizing I'd forgotten the "self" parameter on the decl of f9. This is just a papercut, but it seems like a big one to me. Fixing this--that is, signalling an error like "method f9 is declared without a self parameter"--would presumably require a pass in resolve which scanned for methods without a self parameter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.P-lowLow priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions