-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError raised by JRuby during keyword argument checking while the call is perfectly legit #3760
Comments
OK, so narrowed it down to JRuby having different rules than MRI when a method is given a hash as argument, and also has keyword arguments. I've been testing a few cases, and it seems that MRI's rule in this case is that any key that is not a symbol is fed into the argument (that does include strings), any key that is a symbol is interpreted as a keyword argument Testcase:
MRI:
JRuby 9.0.5.0
|
Thanks for the reduction, @doudou. I'll poke at this a bit this morning. |
The problem appears to be that we try to coerce keys to a string-like thing when we are walking keys we're not sure should be in the kwargs processing. We need the string for the hash lookup. I believe we should only perform this search for keys that actually are string-like, or perhaps only symbols. |
This is unlikely to make 9.1 because of some key issues we have to fix:
The main piece that's missing is that we don't treat an incoming kwarg-able hash as potentially containing both kwarg symbols and non-kwarg pairs. We need a step before arity-checking and argument assignment that breaks apart such hashes into kwargable and non-kwargable parts. |
I think @enebo's nearly-ready args work will probably fix this. |
Fixed in commit c183943. |
Environment
jruby 9.0.5.0 (2.2.3) 2016-01-26 7bee00d Java HotSpot(TM) 64-Bit Server VM 25.77-b03 on 1.8.0_77-b03 +jit [linux-amd64]
onLinux squidock 4.5.0-040500-generic #201603140130 SMP Mon Mar 14 05:32:22 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
(Kubuntu 15.10)Ran with
--debug -G
, but the problem also appears with no command line options.Noteworthy gems: facets (but not only very little of it activated), concurrent-ruby. The code that causes the problem is not multithreaded.
Expected Behaviour
I'm calling a method whose signature is
def process_events_synchronous(seeds = Hash.new, initial_errors = Array.new, enable_scheduler: false)
The call line isengine.process_events_synchronous(seeds)
Links to the actual called method and the calling site
To reproduce,
I expect to enter the called method.
Actual Behaviour
JRuby raises a TypeError exception complaining that
XXXX is not a string
where 'XXX' looks like the result of the caller's #inspect. The first line of the TypeError backtrace on the Ruby side is bogus (see #3624). Removing the keyword argument enable_scheduler makes the call pass as expected. The full backtrace reportsThe text was updated successfully, but these errors were encountered: