JRuby can not interpret keyword argument when placed after positional argument in block #4319

Closed
axfcampos opened this Issue Nov 18, 2016 · 3 comments

Projects

None yet

3 participants

@axfcampos

Hey there 👋

Environment

Running jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 Java HotSpot(TM) 64-Bit Server VM 25.74-b02 on 1.8.0_74-b02 [darwin-x86_64] on Darwin axfcampos.local 15.6.0 Darwin Kernel Version 15.6.0: Mon Aug 29 20:21:34 PDT 2016; root:xnu-3248.60.11~1/RELEASE_X86_64 x86_64

Expected Behavior

Example code:

def hello
  yield(1, b: 2)
end

hello do |a, b:|
  puts a, b
end

Output in MRI 2.3.1:

1
2

Actual Behavior

Output in JRuby:

ArgumentError: missing keyword: b
@enebo enebo added this to the JRuby 9.1.7.0 milestone Nov 18, 2016
@flash-gordon
flash-gordon commented Nov 27, 2016 edited

I came across the same issue, though I can't reproduce it with your example. For me it fails with

ruby -e "proc { |_, a:| }.call(1, a: 1)"

Because of it I got a couple of pending examples in one of my gems.


java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 Java HotSpot(TM) 64-Bit Server VM 25.25-b02 on 1.8.0_25-b17 +jit [darwin-x86_64]

macOS Sierra 10.12.2 Beta (16C48b)

@enebo
Member
enebo commented Nov 30, 2016

I spent some time on this and will try and get something on this shortly but this is not broken once the code is JITed. Both interp and full interp fail but that makes sense since they both use the same code. I am confused though. I was fairly certain the JIT called through the same method as well. So something in JIT changes this behavior...

@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
  instructions.
RubyProc will take kwargs into consideration when re-processing the incoming
  argument list.  I am hoping to delete this code in a future commit.
4e4935e
@enebo enebo closed this in 4e4935e Dec 2, 2016
@flash-gordon

@enebo I checked my case on JRuby's master and it works fine, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment