proc with extra args incorrectly binds wrong post args #2485

enebo opened this Issue Jan 19, 2015 · 3 comments


None yet

3 participants

enebo commented Jan 19, 2015

This test in mri test suite shows it (and quite a bit more):

pr = proc {|a=:a,b=:b,c=:c,d,e|


recv_post_arg incorrectly binds d and e to 5,6 instead of 4,5.

@enebo enebo added this to the JRuby milestone Jan 19, 2015
@enebo enebo modified the milestone: JRuby Jul 14, 2015

For the record, it's not related to the array:

pr = proc {|a=:a,b=:b,c=:c,d,e|

#=> [1, 2, 3, 5, 6]
headius commented Aug 24, 2016

Still failing as of

@enebo enebo added this to the JRuby milestone Aug 24, 2016
enebo commented Aug 24, 2016

I have this fixed locally but I am terribly uncomfortable with my fixes and will not check them in for The actual issue (@phlui61 is correct Array is not part of this although the test case I got from MRI happens to wrap in an array) is that our recv_post_args instr expects to walk from end of incoming arg list. In this case, we pass in more args than can be filled so we walk from the extra arg back.

My fix corrects procs to cull their arg list to match the blocks expected arity. I am not in love with that solution partially because we have to construct a second args list. MRI as I discovered counts forward and calculates where post args begin. That is a better solution and one we should do.

@enebo enebo modified the milestone: JRuby, JRuby Nov 7, 2016
@enebo enebo added a commit that closed this issue Dec 2, 2016
@enebo enebo Fixes #4319. JRuby can not interpret keyword argument when placed aft…
…er positional argument in block

Fixes #2485. proc with extra args incorrectly binds wrong post args

ReceivePostReqdArgInstr now records whether we use rest args and how many opt
  args are processed.  Using these two new variables this instruction will now
  count forward in cases where we have too many arguments passed in (this only
  occurs for procs).
IRBuilder has been changed to pass Signature for setting up pre and post arg
RubyProc will take kwargs into consideration when re-processing the incoming
  argument list.  I am hoping to delete this code in a future commit.
@enebo enebo closed this in 4e4935e Dec 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment