`lambda {|a, b=nil|}.curry(3)` used to silently return a curried Proc;
CRuby raises `ArgumentError` because the lambda accepts at most 2 args.
Use `self.parameters` to compute the upper bound (count `:req`/`:opt`
entries, unbounded if `:rest`/`:keyrest` is present) and add the
corresponding range check alongside the existing minimum check.
close#2855
Co-authored-by: Claude <noreply@anthropic.com>
Added complete call-seq documentation for all extended Proc methods in
mrblib/proc.rb (6 methods):
## Proc Extension Methods:
- ===: case equality operator for use in case statements, enables proc
objects as targets in when clauses for pattern matching
- yield: compatibility method equivalent to call, provided for API
consistency with block yield semantics
- to_proc: protocol method that returns self, part of the standard
to_proc conversion protocol for Proc objects
- curry: creates curried procs for partial application and functional
programming patterns, supports optional arity specification with
proper lambda arity validation
- << (left composition): proc composition operator that calls other_proc
first then this proc, enabling right-to-left function composition
- >> (right composition): proc composition operator that calls this proc
first then other_proc, enabling left-to-right function composition
Co-authored-by: Atlassian Rovo Dev
Make "N for M" into the form "given N, expected M".
As I worked, I noticed that the `argnum_error()` function had a part to include the method name in the message.
I think this part is no longer needed by https://github.com/mruby/mruby/pull/5394.
- Before this patch
```console
% bin/mruby -e '[1, 2, 3].each 0'
trace (most recent call last):
[1] -e:1
-e:1:in each: 'each': wrong number of arguments (1 for 0) (ArgumentError)
```
- After this patch
```console
% bin/mruby -e '[1, 2, 3].each 0'
trace (most recent call last):
[1] -e:1
-e:1:in each: wrong number of arguments (given 1, expected 0) (ArgumentError)
```