Skip to content

Conversation

@jiribenes
Copy link
Contributor

@jiribenes jiribenes commented Nov 14, 2025

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:

Screenshot 2025-11-14 at 19 12 15 Screenshot 2025-11-14 at 18 53 47 Screenshot 2025-11-14 at 19 13 04 Screenshot 2025-11-14 at 19 14 05 Screenshot 2025-11-14 at 19 21 00

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.

@jiribenes jiribenes added errormessage area:typer experiment Experimental branch, do not merge! labels Nov 14, 2025
@jiribenes jiribenes changed the title Experiment: 'did you mean' for mismatched args/params Experiment: complete args/params matching Nov 14, 2025
@jiribenes jiribenes changed the title Experiment: complete args/params matching A more complete error message when args/params do not match Nov 14, 2025
@jiribenes jiribenes removed the experiment Experimental branch, do not merge! label Nov 14, 2025
@jiribenes jiribenes marked this pull request as ready for review November 14, 2025 18:18
}

if (!targsOk || !vargsOk || !bargsOk) {
Context.abort(s"Wrong number of arguments to ${name}: expected ${expected}, but got ${got}")
Copy link
Contributor Author

@jiribenes jiribenes Nov 14, 2025

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?

Comment on lines +1276 to +1280
private def assertArgsParamsAlign(
name: String,
gotTypes: Int, gotValues: Int, gotBlocks: Int,
expectedTypes: Int, expectedValues: Int, expectedBlocks: Int
)(using Context): Unit = {
Copy link
Contributor Author

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 :)

@jiribenes
Copy link
Contributor Author

Merging, happy to revise this later.

@jiribenes jiribenes merged commit 84c4513 into master Nov 16, 2025
6 checks passed
@jiribenes jiribenes deleted the jiribenes/experiment/args-vs-params-checking branch November 16, 2025 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants