-
Notifications
You must be signed in to change notification settings - Fork 40
A more complete error message when args/params do not match #1205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A more complete error message when args/params do not match #1205
Conversation
| } | ||
|
|
||
| if (!targsOk || !vargsOk || !bargsOk) { | ||
| Context.abort(s"Wrong number of arguments to ${name}: expected ${expected}, but got ${got}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT about the message?
We could have some alternate messages here like:
- "${name} expected ... but got ..."
- "Argument mismatch: ${name} expected ... but got ..."
We could also avoid repeating the word arguments everywhere:
"Wrong number of arguments to XYZ: expected 4 value arguments and 2 block arguments, but got 3 value arguments and no block arguments" is a real mouthful.
Would something like "Wrong number of arguments to XYZ: expected 4 values and 2 blocks, but got 3 values and no blocks" be better?
| private def assertArgsParamsAlign( | ||
| name: String, | ||
| gotTypes: Int, gotValues: Int, gotBlocks: Int, | ||
| expectedTypes: Int, expectedValues: Int, expectedBlocks: Int | ||
| )(using Context): Unit = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The signature uses Ints because I couldn't find reasonable common types between the type checking of a block literal and of a function call 😭. (I could also use List[_] everywhere, but I'm not a fan of pretending like that's a better design)
I'd much prefer these to be some specific lists of concrete types :)
|
Merging, happy to revise this later. |
Before, Effekt would early exit on "expected 1 value argument but got 0", now it also says that, in addition, it did not expect a block argument!
There's also some useful hints:
I don't want to add new neg tests for this because I think the message could be improved even more and I don't want to stabilise it for now.