Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.7.0.pre1
-
Fix Version/s: JRuby 1.7.0.pre2
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
Given a file `args_error.rb` with
def my_meth(a) end my_meth 1, 2
In JRuby, this produces:
ArgumentError: wrong number of arguments (2 for 1) (root) at args_error.rb:4
In MRI 1.9:
args_error.rb:1:in `my_meth': wrong number of arguments (2 for 1) (ArgumentError) from args_error.rb:4:in `<main>'
In MRI 1.8.7:
args_error.rb:4:in `my_meth': wrong number of arguments (2 for 1) (ArgumentError) from args_error.rb:4
(Only the line number change)
The MRI version (and Rbx too by the way) mentions the method name.
I think this can be helpful, to easily understand what might be the problem without needing to go to the caller place, and when the call is dynamic (#send).
For the location, 1.8 seems to mention the caller location, while 1.9 shows the callee location (and likely showing the line of the method definition in its file, which can be very helpful).
A certain portion of this is due to our adding "Rubinius-style" backtraces in 1.6, which structure things a bit differently. In MRI backtrace mode, we're a bit closer:
But we show the call site rather than the called method partially because we argument check a lot earlier than MRI or Rubinius do (i.e. before we even enter the method). I'm playing with at least getting the actual called name into the error, but getting the called method's line number might be harder.