S0114: cannot infer lambda parameter type
Generated from rellum-diagnostics/src/db.rs.
Explanation
Lambda parameter types can be inferred only from an expected function type, such as a generic function parameter T -> U. Without that context, the compiler cannot type-check the lambda body or choose the function type to lower.
Common causes
- assigning a lambda without parameter annotations
- passing a lambda where the expected function type is unknown
- calling a generic higher-order function without enough argument context
Canonical fixes
- add a parameter type annotation
Before:
f = fn(x) => x + 1
After:
f = fn(x: Int) => x + 1
- pass the lambda to a function whose parameter type supplies context
Before:
f = fn(x) => x * 2
After:
doubled = map(nums, fn(x) => x * 2)
Code example
f = fn(x) => x + 1