Skip to content

Confusing error message for use of old lambda syntax #2867

Closed
@catamorphism

Description

@catamorphism
fn f(v: ~[int]) {
  for v.each {|z| log(error, z); };
}

I used the old lambda syntax and got this error message:

/Users/TimChevalier/Scratch/f.rs:3:8: 3:34 error: mismatched types: expected `fn(&&int)` but found `fn()` (incorrect number of function parameters)
/Users/TimChevalier/Scratch/f.rs:3   for v.each {|z| log(error, z); };
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/TimChevalier/Scratch/f.rs:3:8: 3:34 error: mismatched types: expected `fn(&&int) -> bool` but found `fn() -> bool` (incorrect number of function parameters)
/Users/TimChevalier/Scratch/f.rs:3   for v.each {|z| log(error, z); };
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~

It took me a good 5 minutes to figure out what I was doing wrong there. Surely there could be a better error message for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frontendArea: Compiler frontend (errors, parsing and HIR)A-type-systemArea: Type system

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions