Skip to content

Lambdas have terrible errors

fn test() {
    // unsafe {
        let lambda = fn() { method(); };
        lambda();
    // }
}


error: Expected lambda to be a unit
  ┌─ testinput:6:9
  
5          let lambda = fn() { method(); };
               ------ lambda is a variable
6          lambda();
           ^^^^^^ Expected a unit

error: Values of type uint<1> must be used
  ┌─ testinput:6:9
  
6          lambda();
           ^^^^^^^^ This must be used
  
  = consider discarding value explicitly
  
6          let _ = lambda();
           ++++++++
  • Where does the uint<1> come from?
  • Help on how to call lambdas when used as unit