Improve method signature / argument validation
Created by: myronmarston
This is some further changes on top of #543.
I've done a bit of refactoring, renamed some things to reflect new realities (e.g. it's not just an arity check anymore), and fixed a couple of bugs I noticed when playing around with kw args.
Things I still want to consider doing:
-
There's an old arity check for and_yield that should be updated to use this. -
I'd still like to consider raising an error message with all of the problems rather than just the first discovered problem. I think this is simpler with the current code structure than when we discussed it before. Nevermind, I've decided I'm ok with how it is. -
The wrong number of args message may not match up with the numbers in the message that ruby generates, because we look at non-kw args and kw args separately for validation purposes but ruby kind of includes both in its concept of arity
. The current message may be confusing and we should look more into it.
@xaviershay, the commits are pretty self-contained and since there are a bunch of changes made for different reasons (generally explained in the commit message), you may want to review this commit-by-commit.