prql
prql copied to clipboard
Better error message for missing args
from film
select [film_id, lag film_id]
... produces:
Error:
╭─[:2:18]
│
2 │ select [film_id, lag film_id]
· ─────┬─────
· ╰─────── function std.select, param `columns` expected type `column`, but found type `func infer -> column`
───╯
We should add a hint here, saying "Have you forgot an argument to function std.lag?"
This error is thrown here: https://github.com/prql/prql/blob/9831c244d4bf3331744de9536d5639bbaab361bc/prql-compiler/src/semantic/type_resolver.rs#L73-L78
TODO:
- check if
found_tyis aTy::Function& check thatexpected_tyis not, - add hint via calling
Error::with_help(...).
Name of the function called can be obtained by destructing found.kind and matching it to ExprKind::Closure, which contains Closure::name. If expr does not match or closure does not specify a name, fallback to a message "Have you forgot an argument in this function call?"
Good onboarding issue! I can take a swing at this soon if no one gets to it (I wouldn't start before midweek though)